/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* bos720 src/bos/kernel/sys/mac.h 1.6.1.2                                */
/*                                                                        */
/* Licensed Materials - Property of IBM                                   */
/*                                                                        */
/* Restricted Materials of IBM                                            */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2006,2011              */
/* All Rights Reserved                                                    */
/*                                                                        */
/* US Government Users Restricted Rights - Use, duplication or            */
/* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.      */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
/* @(#)06	1.6.1.2  src/bos/kernel/sys/mac.h, syssmls, bos720 7/15/11 03:10:50 */
/*
 *   COMPONENT_NAME: SYSSMLS
 *
 *   ORIGINS: 27, 269
 *
 *
 *   (C) COPYRIGHT International Business Machines Corp. 1988,2006
 *   All Rights Reserved
 *   Licensed Materials - Property of IBM
 *   US Government Users Restricted Rights - Use, duplication or
 *   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
 *
 */
/*
 * Copyright (c) 1994-2004 by Innovative Security Systems, Inc.
 * All rights reserved.
 */

#ifndef _SYS_MAC_H
#define _SYS_MAC_H

/*
 * The sensitivity labels and information labels are implemented as bitmaps.
 * The kernel bitmap macros and functions are used as much as possible.
 */

#include <sys/types.h>
#include <sys/systemcfg.h>

#ifdef	__cplusplus
extern "C" {
#endif

#define LABEL_ENCODINGS_FILE "/etc/security/enc/LabelEncodings"

/*
 * These are the values for the SL and TL format fields.
 */
#define STDSL_FORMAT 0	/* Standard */
#define SLSL_FORMAT 1	/* System Low */
#define SHSL_FORMAT 2	/* System High */
#define STDTL_FORMAT 0	/* Standard */
#define SLTL_FORMAT 1	/* System Low */
#define SHTL_FORMAT 2   /* System High */
#define NOTL_FORMAT 3	/* NO TL */

/*
 * These are the strings used in user space to map to the special format
 * field values.
 */
#define SLSL_STR "SLSL"
#define SHSL_STR "SHSL"
#define SLTL_STR "SLTL"
#define SHTL_STR "SHTL"
#define NOTL_STR "NOTL"

#define NUM_SC 1024	/* number of categories/comparments per label */
#define NUM_SM 256	/* number of markings per label */
#define	NUM_SQ 32000	/* maximum classification allowed */

#define SC_32 32	/* number of 32 bit words for compartments */
#define SM_32 8		/* number of 32 bit words for markings */

/*
 * Sensitivity Label and Clearance Label
 */
typedef struct _sl_t {
	short		sl_format;		/* label format field */
	short		sl_class;		/* classification */
	uint32_t	pad;			/* unused - alignment */
	uint32_t	sl_comp[SC_32];		/* compartments */
} sl_t;

/*
 * Integrity Label
 */
typedef struct _tl_t {
	short	 	tl_format;	/* label format field */
	short		tl_class;	/* classification */
	uint32_t	pad;		/* unused - alignment */
} tl_t;

/* security labels for subject and objects */
typedef struct sec_labels {
	sl_t    sl;                     /* Sensitivity Label */
	sl_t    sl_cl_min;              /* Min SL clearance Label */
	sl_t    sl_cl_max;              /* Max SL clearance Label */
	tl_t    tl;                     /* Integrity Label */
	tl_t    tl_cl_min;              /* Min TL clearance Label */
	tl_t    tl_cl_max;              /* Max TL clearance Label */
} sec_labels_t;

#define __MLS_OS()	__MLS_KERNEL()

#ifdef __64BIT_KERNEL
extern sl_t sys_max_sl;
extern sl_t sys_min_sl;
extern tl_t sys_max_tl;
extern tl_t sys_min_tl;
#endif /* __64BIT_KERNEL */

/* Handy check if a TL is a NOTL. */
#define isNOTL(a)	((a)->tl_format == NOTL_FORMAT)

/* Domain definiton */
typedef sl_t dom_t;
#ifdef	__cplusplus
}
#endif

#endif /* _SYS_MAC_H */
