145916cd2Sjpk /*
245916cd2Sjpk  * CDDL HEADER START
345916cd2Sjpk  *
445916cd2Sjpk  * The contents of this file are subject to the terms of the
545916cd2Sjpk  * Common Development and Distribution License (the "License").
645916cd2Sjpk  * You may not use this file except in compliance with the License.
745916cd2Sjpk  *
845916cd2Sjpk  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
945916cd2Sjpk  * or http://www.opensolaris.org/os/licensing.
1045916cd2Sjpk  * See the License for the specific language governing permissions
1145916cd2Sjpk  * and limitations under the License.
1245916cd2Sjpk  *
1345916cd2Sjpk  * When distributing Covered Code, include this CDDL HEADER in each
1445916cd2Sjpk  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1545916cd2Sjpk  * If applicable, add the following below this CDDL HEADER, with the
1645916cd2Sjpk  * fields enclosed by brackets "[]" replaced with your own identifying
1745916cd2Sjpk  * information: Portions Copyright [yyyy] [name of copyright owner]
1845916cd2Sjpk  *
1945916cd2Sjpk  * CDDL HEADER END
2045916cd2Sjpk  */
2145916cd2Sjpk /*
2245916cd2Sjpk  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
2345916cd2Sjpk  * Use is subject to license terms.
2445916cd2Sjpk  */
2545916cd2Sjpk 
2645916cd2Sjpk #ifndef	_LABEL_MACRO_H
2745916cd2Sjpk #define	_LABEL_MACRO_H
2845916cd2Sjpk 
2945916cd2Sjpk #include <sys/types.h>
3045916cd2Sjpk 
3145916cd2Sjpk #ifdef	__cplusplus
3245916cd2Sjpk extern "C" {
3345916cd2Sjpk #endif
3445916cd2Sjpk 
3545916cd2Sjpk /* PRIVATE ONLY TO THE LABEL LIBRARY.  DO NOT USE ELSEWHERE */
3645916cd2Sjpk 
3745916cd2Sjpk /* Actual Binary Label Structure Definitions */
3845916cd2Sjpk 
3945916cd2Sjpk typedef int16_t	_Classification;
4045916cd2Sjpk typedef struct {
4145916cd2Sjpk 	union {
4245916cd2Sjpk 		uint8_t		class_ar[2];
4345916cd2Sjpk 		_Classification	class_chunk;
4445916cd2Sjpk 	} class_u;
4545916cd2Sjpk } Classification_t;
4645916cd2Sjpk 
4745916cd2Sjpk typedef struct {
4845916cd2Sjpk 	uint32_t c1;
4945916cd2Sjpk 	uint32_t c2;
5045916cd2Sjpk 	uint32_t c3;
5145916cd2Sjpk 	uint32_t c4;
5245916cd2Sjpk 	uint32_t c5;
5345916cd2Sjpk 	uint32_t c6;
5445916cd2Sjpk 	uint32_t c7;
5545916cd2Sjpk 	uint32_t c8;
5645916cd2Sjpk } Compartments_t;
5745916cd2Sjpk 
5845916cd2Sjpk typedef struct {
5945916cd2Sjpk 	uint32_t m1;
6045916cd2Sjpk 	uint32_t m2;
6145916cd2Sjpk 	uint32_t m3;
6245916cd2Sjpk 	uint32_t m4;
6345916cd2Sjpk 	uint32_t m5;
6445916cd2Sjpk 	uint32_t m6;
6545916cd2Sjpk 	uint32_t m7;
6645916cd2Sjpk 	uint32_t m8;
6745916cd2Sjpk } Markings_t;
6845916cd2Sjpk 
6945916cd2Sjpk typedef struct _mac_label_impl {
7045916cd2Sjpk 	uint8_t id;		/* Magic to say label type */
7145916cd2Sjpk 	uint8_t _c_len;		/* Number of Compartment words */
7245916cd2Sjpk 	Classification_t classification;
7345916cd2Sjpk 	Compartments_t compartments;
7445916cd2Sjpk } _mac_label_impl_t;
7545916cd2Sjpk 
7645916cd2Sjpk typedef _mac_label_impl_t	_blevel_impl_t,		/* compatibility */
7745916cd2Sjpk 				_bslabel_impl_t,	/* Sensitivity Label */
7845916cd2Sjpk 				_bclear_impl_t;		/* Clearance */
7945916cd2Sjpk 
8045916cd2Sjpk typedef struct _binary_information_label_impl {	/* Information Label */
8145916cd2Sjpk 	_mac_label_impl_t	binformation_level;
8245916cd2Sjpk 	Markings_t markings;
8345916cd2Sjpk } _bilabel_impl_t;
8445916cd2Sjpk 
8545916cd2Sjpk typedef struct _binary_cmw_label_impl {		/* CMW Label */
8645916cd2Sjpk 	_bslabel_impl_t bcl_sensitivity_label;
8745916cd2Sjpk 	_bilabel_impl_t bcl_information_label;
8845916cd2Sjpk } _bclabel_impl_t;
8945916cd2Sjpk 
9045916cd2Sjpk typedef struct _binary_level_range_impl {	/* Level Range */
9145916cd2Sjpk 	_mac_label_impl_t lower_bound;
9245916cd2Sjpk 	_mac_label_impl_t upper_bound;
9345916cd2Sjpk } _brange_impl_t, brange_t;
9445916cd2Sjpk 
95*b9dac67bSrica #define	NMLP_MAX	0x10
96*b9dac67bSrica #define	NSLS_MAX	0x4
97*b9dac67bSrica 
98*b9dac67bSrica typedef _mac_label_impl_t blset_t[NSLS_MAX];
99*b9dac67bSrica 
10045916cd2Sjpk /* Label Identifier Types */
10145916cd2Sjpk 
10245916cd2Sjpk #define	SUN_MAC_ID	0x41	/* MAC label, legacy SUN_SL_ID */
10345916cd2Sjpk #define	SUN_UCLR_ID	0x49	/* User Clearance, legacy SUN_CLR_ID */
10445916cd2Sjpk 
10545916cd2Sjpk #define	_C_LEN		8	/* number of compartments words */
10645916cd2Sjpk 
10745916cd2Sjpk /* m_label_t macros */
10845916cd2Sjpk #define	_MTYPE(l, t) \
10945916cd2Sjpk 	(((_mac_label_impl_t *)(l))->id == (t))
11045916cd2Sjpk 
11145916cd2Sjpk #define	_MSETTYPE(l, t) \
11245916cd2Sjpk 	(((_mac_label_impl_t *)(l))->id = (t))
11345916cd2Sjpk 
11445916cd2Sjpk #define	_MGETTYPE(l)	(((_mac_label_impl_t *)(l))->id)
11545916cd2Sjpk 
11645916cd2Sjpk #define	_MEQUAL(l1, l2) \
11745916cd2Sjpk 	(LCLASS(l1) == LCLASS(l2) && \
11845916cd2Sjpk 	(l1)->_comps.c1 == (l2)->_comps.c1 && \
11945916cd2Sjpk 	(l1)->_comps.c2 == (l2)->_comps.c2 && \
12045916cd2Sjpk 	(l1)->_comps.c3 == (l2)->_comps.c3 && \
12145916cd2Sjpk 	(l1)->_comps.c4 == (l2)->_comps.c4 && \
12245916cd2Sjpk 	(l1)->_comps.c5 == (l2)->_comps.c5 && \
12345916cd2Sjpk 	(l1)->_comps.c6 == (l2)->_comps.c6 && \
12445916cd2Sjpk 	(l1)->_comps.c7 == (l2)->_comps.c7 && \
12545916cd2Sjpk 	(l1)->_comps.c8 == (l2)->_comps.c8)
12645916cd2Sjpk 
12745916cd2Sjpk #define	SUN_INVALID_ID	0	/* uninitialized label */
12845916cd2Sjpk #define	SUN_CMW_ID	0x83	/* 104 - total bytes in CMW Label */
12945916cd2Sjpk #define	SUN_SL_ID	0x41	/* 36 - total bytes in Sensitivity Label */
13045916cd2Sjpk #define	SUN_SL_UN	0xF1	/* undefined Sensitivity Label */
13145916cd2Sjpk #define	SUN_IL_ID	0x42	/* 68 - total bytes in Information Label */
13245916cd2Sjpk #define	SUN_IL_UN	0x73	/* undefined Information Label */
13345916cd2Sjpk #define	SUN_CLR_ID	0x49	/* 36 - total bytes in Clearance */
13445916cd2Sjpk #define	SUN_CLR_UN	0xF9	/* undefined Clearance */
13545916cd2Sjpk 
13645916cd2Sjpk #define	_bcl_sl		bcl_sensitivity_label
13745916cd2Sjpk #define	_bcl_il		bcl_information_label
13845916cd2Sjpk #define	_bslev_il	binformation_level
13945916cd2Sjpk 
14045916cd2Sjpk #define	_lclass		classification
14145916cd2Sjpk #ifdef	_BIG_ENDIAN
14245916cd2Sjpk #define	LCLASS(slp)	((slp)->_lclass.class_u.class_chunk)
14345916cd2Sjpk #define	LCLASS_SET(slp, l)	((slp)->_lclass.class_u.class_chunk = (l))
14445916cd2Sjpk #else
14545916cd2Sjpk #define	LCLASS(slp)	\
14645916cd2Sjpk 	((_Classification)(((slp)->_lclass.class_u.class_ar[0] << 8) | \
14745916cd2Sjpk 	(slp)->_lclass.class_u.class_ar[1]))
14845916cd2Sjpk #define	LCLASS_SET(slp, l)	\
14945916cd2Sjpk 	((slp)->_lclass.class_u.class_ar[0] = (uint8_t)((l)>> 8), \
15045916cd2Sjpk 	(slp)->_lclass.class_u.class_ar[1] = (uint8_t)(l))
15145916cd2Sjpk #endif	/* _BIG_ENDIAN */
15245916cd2Sjpk #define	_comps		compartments
15345916cd2Sjpk 
15445916cd2Sjpk #define	_iid		_bslev_il.id
15545916cd2Sjpk #define	_i_c_len		_bslev_il._c_len
15645916cd2Sjpk #define	_iclass		_bslev_il._lclass
15745916cd2Sjpk #ifdef	_BIG_ENDIAN
15845916cd2Sjpk #define	ICLASS(ilp)	((ilp)->_iclass.class_u.class_chunk)
15945916cd2Sjpk #define	ICLASS_SET(ilp, l)	((ilp)->_iclass.class_u.class_chunk = (l))
16045916cd2Sjpk #else
16145916cd2Sjpk #define	ICLASS(ilp)	\
16245916cd2Sjpk 	((_Classification)(((ilp)->_iclass.class_u.class_ar[0] << 8) | \
16345916cd2Sjpk 	(ilp)->_iclass.class_u.class_ar[1]))
16445916cd2Sjpk #define	ICLASS_SET(ilp, l)	\
16545916cd2Sjpk 	((ilp)->_iclass.class_u.class_ar[0] = (uint8_t)((l)>> 8), \
16645916cd2Sjpk 	(ilp)->_iclass.class_u.class_ar[1] = (uint8_t)(l))
16745916cd2Sjpk #endif	/* _BIG_ENDIAN */
16845916cd2Sjpk #define	_icomps		_bslev_il._comps
16945916cd2Sjpk #define	_imarks		markings
17045916cd2Sjpk 
17145916cd2Sjpk /* Manifest Constant Values */
17245916cd2Sjpk 
17345916cd2Sjpk #define	LOW_CLASS	0	/* Admin_Low classification value */
17445916cd2Sjpk #define	HIGH_CLASS	0x7FFF	/* Admin_High classification value */
17545916cd2Sjpk #define	EMPTY_SET	0	/* Empty compartments and markings set */
17645916cd2Sjpk #define	UNIVERSAL_SET	0xFFFFFFFFU	/* Universal compartments and */
17745916cd2Sjpk 					/* markings set */
17845916cd2Sjpk 
17945916cd2Sjpk /* Construct initial labels */
18045916cd2Sjpk 
18145916cd2Sjpk #define	_LOW_LABEL(l, t) \
18245916cd2Sjpk 	((l)->id = t, (l)->_c_len = _C_LEN, LCLASS_SET(l, LOW_CLASS), \
18345916cd2Sjpk 	(l)->_comps.c1 = (l)->_comps.c2 = (l)->_comps.c3 = (l)->_comps.c4 = \
18445916cd2Sjpk 	(l)->_comps.c5 = (l)->_comps.c6 = (l)->_comps.c7 = (l)->_comps.c8 = \
18545916cd2Sjpk 	EMPTY_SET)
18645916cd2Sjpk 
18745916cd2Sjpk #define	_HIGH_LABEL(l, t) \
18845916cd2Sjpk 	((l)->id = t, (l)->_c_len = _C_LEN, LCLASS_SET(l, HIGH_CLASS), \
18945916cd2Sjpk 	(l)->_comps.c1 = (l)->_comps.c2 = (l)->_comps.c3 = (l)->_comps.c4 = \
19045916cd2Sjpk 	(l)->_comps.c5 = (l)->_comps.c6 = (l)->_comps.c7 = (l)->_comps.c8 = \
19145916cd2Sjpk 	UNIVERSAL_SET)
19245916cd2Sjpk 
19345916cd2Sjpk /* Macro equivalents */
19445916cd2Sjpk 
19545916cd2Sjpk /* Is this memory a properly formatted label of type t? */
19645916cd2Sjpk #define	BLTYPE(l, t) \
19745916cd2Sjpk 	((t) == SUN_CMW_ID ? \
19845916cd2Sjpk 	(((_bclabel_impl_t *)(l))->_bcl_sl.id == SUN_SL_ID || \
19945916cd2Sjpk 	((_bclabel_impl_t *)(l))->_bcl_sl.id == SUN_SL_UN) && \
20045916cd2Sjpk 	(((_bclabel_impl_t *)(l))->_bcl_il._iid == SUN_IL_ID || \
20145916cd2Sjpk 	((_bclabel_impl_t *)(l))->_bcl_il._iid == SUN_IL_UN) : \
20245916cd2Sjpk 	((_mac_label_impl_t *)(l))->id == (t))
20345916cd2Sjpk 
20445916cd2Sjpk /* Are the levels of these labels equal? */
20545916cd2Sjpk #define	BLEQUAL(l1, l2) \
20645916cd2Sjpk 	_BLEQUAL((_mac_label_impl_t *)(l1), (_mac_label_impl_t *)(l2))
20745916cd2Sjpk 
20845916cd2Sjpk #define	_BLEQUAL(l1, l2) \
20945916cd2Sjpk 	(LCLASS(l1) == LCLASS(l2) && \
21045916cd2Sjpk 	(l1)->_comps.c1 == (l2)->_comps.c1 && \
21145916cd2Sjpk 	(l1)->_comps.c2 == (l2)->_comps.c2 && \
21245916cd2Sjpk 	(l1)->_comps.c3 == (l2)->_comps.c3 && \
21345916cd2Sjpk 	(l1)->_comps.c4 == (l2)->_comps.c4 && \
21445916cd2Sjpk 	(l1)->_comps.c5 == (l2)->_comps.c5 && \
21545916cd2Sjpk 	(l1)->_comps.c6 == (l2)->_comps.c6 && \
21645916cd2Sjpk 	(l1)->_comps.c7 == (l2)->_comps.c7 && \
21745916cd2Sjpk 	(l1)->_comps.c8 == (l2)->_comps.c8)
21845916cd2Sjpk 
21945916cd2Sjpk /* Does the level of l1 dominate that of l2? */
22045916cd2Sjpk #define	BLDOMINATES(l1, l2) \
22145916cd2Sjpk 	_BLDOMINATES((_mac_label_impl_t *)(l1), (_mac_label_impl_t *)(l2))
22245916cd2Sjpk 
22345916cd2Sjpk #define	_BLDOMINATES(l1, l2) (LCLASS(l1) >= LCLASS(l2) && \
22445916cd2Sjpk 	(l2)->_comps.c1 == ((l1)->_comps.c1 & (l2)->_comps.c1) && \
22545916cd2Sjpk 	(l2)->_comps.c2 == ((l1)->_comps.c2 & (l2)->_comps.c2) && \
22645916cd2Sjpk 	(l2)->_comps.c3 == ((l1)->_comps.c3 & (l2)->_comps.c3) && \
22745916cd2Sjpk 	(l2)->_comps.c4 == ((l1)->_comps.c4 & (l2)->_comps.c4) && \
22845916cd2Sjpk 	(l2)->_comps.c5 == ((l1)->_comps.c5 & (l2)->_comps.c5) && \
22945916cd2Sjpk 	(l2)->_comps.c6 == ((l1)->_comps.c6 & (l2)->_comps.c6) && \
23045916cd2Sjpk 	(l2)->_comps.c7 == ((l1)->_comps.c7 & (l2)->_comps.c7) && \
23145916cd2Sjpk 	(l2)->_comps.c8 == ((l1)->_comps.c8 & (l2)->_comps.c8))
23245916cd2Sjpk 
23345916cd2Sjpk /* Does the level of l1 strictly dominate that of l2? */
23445916cd2Sjpk #define	BLSTRICTDOM(l1, l2) (!BLEQUAL(l1, l2) && BLDOMINATES(l1, l2))
23545916cd2Sjpk 
23645916cd2Sjpk /* Is the level of l within the range r? */
23745916cd2Sjpk #define	BLINRANGE(l, r)\
23845916cd2Sjpk 	(BLDOMINATES((l), &((r)->lower_bound)) && \
23945916cd2Sjpk 	BLDOMINATES(&((r)->upper_bound), (l)))
24045916cd2Sjpk 
24145916cd2Sjpk /* Least Upper Bound level l1 and l2 replacing l1 with the result. */
24245916cd2Sjpk #define	BLMAXIMUM(l1, l2) \
24345916cd2Sjpk 	_BLMAXIMUM((_mac_label_impl_t *)(l1), (_mac_label_impl_t *)(l2))
24445916cd2Sjpk 
24545916cd2Sjpk #define	_BLMAXIMUM(l1, l2)\
24645916cd2Sjpk 	(((l1)->_lclass = (LCLASS(l1) < LCLASS(l2)) ? \
24745916cd2Sjpk 	(l2)->_lclass : (l1)->_lclass), \
24845916cd2Sjpk 	(l1)->_comps.c1 |= (l2)->_comps.c1, \
24945916cd2Sjpk 	(l1)->_comps.c2 |= (l2)->_comps.c2, \
25045916cd2Sjpk 	(l1)->_comps.c3 |= (l2)->_comps.c3, \
25145916cd2Sjpk 	(l1)->_comps.c4 |= (l2)->_comps.c4, \
25245916cd2Sjpk 	(l1)->_comps.c5 |= (l2)->_comps.c5, \
25345916cd2Sjpk 	(l1)->_comps.c6 |= (l2)->_comps.c6, \
25445916cd2Sjpk 	(l1)->_comps.c7 |= (l2)->_comps.c7, \
25545916cd2Sjpk 	(l1)->_comps.c8 |= (l2)->_comps.c8)
25645916cd2Sjpk 
25745916cd2Sjpk /* Greatest Lower Bound level l1 and l2 replacing l1 with the result. */
25845916cd2Sjpk #define	BLMINIMUM(l1, l2) \
25945916cd2Sjpk 	_BLMINIMUM((_mac_label_impl_t *)(l1), (_mac_label_impl_t *)(l2))
26045916cd2Sjpk 
26145916cd2Sjpk #define	_BLMINIMUM(l1, l2)\
26245916cd2Sjpk 	(((l1)->_lclass = (LCLASS(l1) > LCLASS(l2)) ? \
26345916cd2Sjpk 	(l2)->_lclass : (l1)->_lclass), \
26445916cd2Sjpk 	(l1)->_comps.c1 &= (l2)->_comps.c1, \
26545916cd2Sjpk 	(l1)->_comps.c2 &= (l2)->_comps.c2, \
26645916cd2Sjpk 	(l1)->_comps.c3 &= (l2)->_comps.c3, \
26745916cd2Sjpk 	(l1)->_comps.c4 &= (l2)->_comps.c4, \
26845916cd2Sjpk 	(l1)->_comps.c5 &= (l2)->_comps.c5, \
26945916cd2Sjpk 	(l1)->_comps.c6 &= (l2)->_comps.c6, \
27045916cd2Sjpk 	(l1)->_comps.c7 &= (l2)->_comps.c7, \
27145916cd2Sjpk 	(l1)->_comps.c8 &= (l2)->_comps.c8)
27245916cd2Sjpk 
27345916cd2Sjpk /* Create Manifest Labels */
27445916cd2Sjpk 
27545916cd2Sjpk /* Write a System_Low CMW Label into this memory. */
27645916cd2Sjpk #define	BCLLOW(l) (BSLLOW(BCLTOSL(l)), BILLOW(BCLTOIL(l)))
27745916cd2Sjpk 
27845916cd2Sjpk /* Write a System_Low Sensitivity Label into this memory. */
27945916cd2Sjpk #define	BSLLOW(l) _BSLLOW((_bslabel_impl_t *)(l))
28045916cd2Sjpk 
28145916cd2Sjpk #define	_BSLLOW(l) \
28245916cd2Sjpk 	((l)->id = SUN_SL_ID, (l)->_c_len = _C_LEN, LCLASS_SET(l, LOW_CLASS), \
28345916cd2Sjpk 	(l)->_comps.c1 = (l)->_comps.c2 = (l)->_comps.c3 = (l)->_comps.c4 = \
28445916cd2Sjpk 	(l)->_comps.c5 = (l)->_comps.c6 = (l)->_comps.c7 = (l)->_comps.c8 = \
28545916cd2Sjpk 	EMPTY_SET)
28645916cd2Sjpk 
28745916cd2Sjpk /* Write a System_High Sensitivity Label into this memory. */
28845916cd2Sjpk #define	BSLHIGH(l) _BSLHIGH((_bslabel_impl_t *)(l))
28945916cd2Sjpk 
29045916cd2Sjpk #define	_BSLHIGH(l) \
29145916cd2Sjpk 	((l)->id = SUN_SL_ID, (l)->_c_len = _C_LEN, LCLASS_SET(l, HIGH_CLASS), \
29245916cd2Sjpk 	(l)->_comps.c1 = (l)->_comps.c2 = (l)->_comps.c3 = (l)->_comps.c4 = \
29345916cd2Sjpk 	(l)->_comps.c5 = (l)->_comps.c6 = (l)->_comps.c7 = (l)->_comps.c8 = \
29445916cd2Sjpk 	UNIVERSAL_SET)
29545916cd2Sjpk 
29645916cd2Sjpk /* Write a System_Low Information Label into this memory. */
29745916cd2Sjpk #define	BILLOW(l) _BILLOW((_bilabel_impl_t *)(l))
29845916cd2Sjpk 
29945916cd2Sjpk #define	_BILLOW(l) \
30045916cd2Sjpk 	((l)->_iid = SUN_IL_ID, (l)->_i_c_len = _C_LEN, \
30145916cd2Sjpk 	ICLASS_SET(l, LOW_CLASS), \
30245916cd2Sjpk 	(l)->_icomps.c1 = (l)->_icomps.c2 = (l)->_icomps.c3 = \
30345916cd2Sjpk 	(l)->_icomps.c4 = (l)->_icomps.c5 = (l)->_icomps.c6 = \
30445916cd2Sjpk 	(l)->_icomps.c7 = (l)->_icomps.c8 = EMPTY_SET, \
30545916cd2Sjpk 	(l)->_imarks.m1 = (l)->_imarks.m2 = (l)->_imarks.m3 = \
30645916cd2Sjpk 	(l)->_imarks.m4 = (l)->_imarks.m5 = (l)->_imarks.m6 = \
30745916cd2Sjpk 	(l)->_imarks.m7 = (l)->_imarks.m8 = EMPTY_SET)
30845916cd2Sjpk 
30945916cd2Sjpk 
31045916cd2Sjpk /* Write a System_Low Sensitivity Label into this memory. */
31145916cd2Sjpk #define	BCLEARLOW(l) _BCLEARLOW((_bclear_impl_t *)(l))
31245916cd2Sjpk 
31345916cd2Sjpk #define	_BCLEARLOW(c) \
31445916cd2Sjpk 	((c)->id = SUN_CLR_ID, (c)->_c_len = _C_LEN, \
31545916cd2Sjpk 	LCLASS_SET(c, LOW_CLASS), \
31645916cd2Sjpk 	(c)->_comps.c1 = (c)->_comps.c2 = (c)->_comps.c3 = (c)->_comps.c4 = \
31745916cd2Sjpk 	(c)->_comps.c5 = (c)->_comps.c6 = (c)->_comps.c7 = (c)->_comps.c8 = \
31845916cd2Sjpk 	EMPTY_SET)
31945916cd2Sjpk 
32045916cd2Sjpk /* Write a System_High Sensitivity Label into this memory. */
32145916cd2Sjpk #define	BCLEARHIGH(l) _BCLEARHIGH((_bclear_impl_t *)(l))
32245916cd2Sjpk 
32345916cd2Sjpk #define	_BCLEARHIGH(c) \
32445916cd2Sjpk 	((c)->id = SUN_CLR_ID, (c)->_c_len = _C_LEN, \
32545916cd2Sjpk 	LCLASS_SET(c, HIGH_CLASS), \
32645916cd2Sjpk 	(c)->_comps.c1 = (c)->_comps.c2 = (c)->_comps.c3 = (c)->_comps.c4 = \
32745916cd2Sjpk 	(c)->_comps.c5 = (c)->_comps.c6 = (c)->_comps.c7 = (c)->_comps.c8 = \
32845916cd2Sjpk 	UNIVERSAL_SET)
32945916cd2Sjpk 
33045916cd2Sjpk /* Write an undefined Sensitivity Label into this memory. */
33145916cd2Sjpk #define	BSLUNDEF(l) (((_bslabel_impl_t *)(l))->id = SUN_SL_UN)
33245916cd2Sjpk 
33345916cd2Sjpk /* Write an undefined Clearance into this memory. */
33445916cd2Sjpk #define	BCLEARUNDEF(c) (((_bclear_impl_t *)(c))->id = SUN_CLR_UN)
33545916cd2Sjpk 
33645916cd2Sjpk /* Retrieve the Sensitivity Label portion of a CMW Label */
33745916cd2Sjpk #define	BCLTOSL(l) ((bslabel_t *)&((_bclabel_impl_t *)(l))->_bcl_sl)
33845916cd2Sjpk 
33945916cd2Sjpk /* Retrieve the Information Label portion of a CMW Label */
34045916cd2Sjpk #define	BCLTOIL(l) ((_bilabel_impl_t *)&((_bclabel_impl_t *)(l))->_bcl_il)
34145916cd2Sjpk 
34245916cd2Sjpk /* Copy the Sensitivity Label portion from a CMW Label */
34345916cd2Sjpk #define	GETCSL(l1, l2) \
34445916cd2Sjpk 	(*((_bslabel_impl_t *)(l1)) = ((_bclabel_impl_t *)(l2))->_bcl_sl)
34545916cd2Sjpk 
34645916cd2Sjpk /* Replace the Sensitivity Label portion of a CMW Label */
34745916cd2Sjpk #define	SETCSL(l1, l2) \
34845916cd2Sjpk 	(((_bclabel_impl_t *)(l1))->_bcl_sl = *((_bslabel_impl_t *)(l2)))
34945916cd2Sjpk 
35045916cd2Sjpk /* Set type of this memory to the label type 't' */
35145916cd2Sjpk #define	SETBLTYPE(l, t) (((_bclabel_impl_t *)(l))->_bcl_sl.id = (t))
35245916cd2Sjpk 
35345916cd2Sjpk #define	GETBLTYPE(l)	(((const _bclabel_impl_t *)(l))->_bcl_sl.id)
35445916cd2Sjpk 
35545916cd2Sjpk #ifdef	__cplusplus
35645916cd2Sjpk }
35745916cd2Sjpk #endif
35845916cd2Sjpk 
35945916cd2Sjpk #endif	/* !_LABEL_MACRO_H */
360