/* <chpdef.h>
 *
 *	Item definitions for the $CHKPRO (check protection) service.
 */
#ifndef _CHPDEF_H
#define _CHPDEF_H

#define CHP$_END	0		/* list end */
#define CHP$_ACCESS	1		/* intended access */
#define CHP$_FLAGS	2		/* read / write flags */
#define CHP$_PRIV	3		/* privilege mask */
#define CHP$_ACMODE	4		/* accessor access mode */
#define CHP$_ACCLASS	5		/* accessor security classification */
#define CHP$_RIGHTS	6		/* rights list */
#ifndef NO_VMS_V6
#define CHP$_ADD_RIGHTS 7		/* additional rights list segments */
#endif
#define CHP$_ADDRIGHTS	7		/* additional rights list segments */
#define CHP$_MODE	8		/* simple access mode */
#define CHP$_MODES	9		/* per action access mode */
#ifndef NO_VMS_V6
#define CHP$_MIN_CLASS	10		/* minimum security classification */
#define CHP$_MAX_CLASS	11		/* maximum security classification */
#endif
#define CHP$_MINCLASS	10		/* minimum security classification */
#define CHP$_MAXCLASS	11		/* maximum security classification */
#define CHP$_OWNER	12		/* object owner UIC */
#define CHP$_PROT	13		/* protection mask */
#define CHP$_ACL	14		/* access control list segment */
#ifndef NO_VMS_V6
#define CHP$_AUDIT_NAME 15		/* audit names returned */
#define CHP$_ALARM_NAME 16		/* alarm names returned */
#define CHP$_MATCHED_ACE 17		/* address of matching ACE */
#endif
#define CHP$_AUDITNAME	15		/* security audit name */
#define CHP$_ALARMNAME	16		/* security alarm name */
#define CHP$_MATCHEDACE 17		/* address of matching ACE */
#define CHP$_PRIVUSED	18		/* mask of privileges used */
#ifndef NO_VMS_V6
#define CHP$_AUDIT_LIST 19		/* address of supplemental audit item list */
#define CHP$_OBJECT_NAME 20		/* object name descriptor */
#define CHP$_OBJECT_CLASS 21		/* object class name descriptor */
#define CHP$_UIC	22		/* accessor UIC */
#define CHP$_OBJECT_SPECIFIC 23		/* object specific longword (for OSR) */
#define CHP$_MAX_CODE	24		/* highest CHP$ item code */
#else
#define CHP$_MAX_CODE	19		/* highest CHP$ item code */
#endif
#ifndef NO_VMS_V6
#define CHP$_CLASS	5
#define CHP$K_MATCHED_ACE_LENGTH 255
#define CHP$K_ALARM_LENGTH	 768
#define CHP$K_AUDIT_LENGTH	1560
#endif

#define CHP$V_SYSPRV	0
#define CHP$V_BYPASS	1
#define CHP$V_UPGRADE	2
#define CHP$V_DOWNGRADE 3
#define CHP$V_GRPPRV	4
#define CHP$V_READALL	5
#define CHP$V_OPER	6
#define CHP$V_GRPNAM	7
#define CHP$V_SYSNAM	8
#define CHP$V_GROUP	9
#define CHP$V_WORLD	10
#define CHP$V_PRMCEB	11
#define CHP$M_SYSPRV	(1<<CHP$V_SYSPRV)	/* 0x01 */
#define CHP$M_BYPASS	(1<<CHP$V_BYPASS)	/* 0x02 */
#define CHP$M_UPGRADE	(1<<CHP$V_UPGRADE)	/* 0x04 */
#define CHP$M_DOWNGRADE (1<<CHP$V_DOWNGRADE)	/* 0x08 */
#define CHP$M_GRPPRV	(1<<CHP$V_GRPPRV)	/* 0x10 */
#define CHP$M_READALL	(1<<CHP$V_READALL)	/* 0x20 */
#define CHP$M_OPER	(1<<CHP$V_OPER)		/* 0x40 */
#define CHP$M_GRPNAM	(1<<CHP$V_GRPNAM)	/* 0x80 */
#define CHP$M_SYSNAM	(1<<CHP$V_SYSNAM)	/* 0x1000 */
#define CHP$M_GROUP	(1<<CHP$V_GROUP)	/* 0x2000 */
#define CHP$M_WORLD	(1<<CHP$V_WORLD)	/* 0x4000 */
#define CHP$M_PRMCEB	(1<<CHP$V_PRMCEB)	/* 0x8000 */
#define CHP$K_NUMBER_OF_PRIVS	12
struct chp$privs_used_bits {
    unsigned chp$v_sysprv	: 1;	/* access via SYSPRV privilege	*/
    unsigned chp$v_bypass	: 1;	/* access via BYPASS privilege	*/
    unsigned chp$v_upgrade	: 1;	/* access via UPGRADE privilege */
    unsigned chp$v_downgrade	: 1;	/* access via DOWNGRADE privilege */
    unsigned chp$v_grpprv	: 1;	/* access via GRPPRV privilege	*/
    unsigned chp$v_readall	: 1;	/* access via READALL privilege */
    unsigned chp$v_oper		: 1;	/* access via OPER privilege */
    unsigned chp$v_grpnam	: 1;	/* access via GRPNAM privilege */
    unsigned chp$v_sysnam	: 1;	/* access via SYSNAM privilege */
    unsigned chp$v_group	: 1;	/* access via GROUP privilege */
    unsigned chp$v_world	: 1;	/* access via WORLD privilege */
    unsigned chp$v_prmceb	: 1;	/* access via PRMCEB privilege */
    unsigned			: 4;
};
#define CHP$V_OBSERVE	0
#define CHP$V_ALTER	1
#define CHP$M_OBSERVE	(1<<CHP$V_OBSERVE)	/* 0x01 */
#define CHP$M_ALTER	(1<<CHP$V_ALTER)	/* 0x02 */
#define CHP$V_READ	0
#define CHP$V_WRITE	1
#define CHP$V_USEREADALL 2
#define CHP$V_AUDIT	3
#define CHP$V_NOFAILAUD 4
#define CHP$V_NOSUCCAUD 5
#define CHP$V_DELETE	6
#define CHP$V_MANDATORY 7
#define CHP$V_FLUSH	8
#define CHP$V_CREATE	9
#define CHP$V_INTERNAL	10
#define CHP$V_SERVER	11
#define CHP$M_READ	(1<<CHP$V_READ)		/* 0x01 */
#define CHP$M_WRITE	(1<<CHP$V_WRITE)	/* 0x02 */
#define CHP$M_USEREADALL (1<<CHP$V_USEREADALL)	/* 0x04 */
#define CHP$M_AUDIT	(1<<CHP$V_AUDIT)	/* 0x08 */
#define CHP$M_NOFAILAUD (1<<CHP$V_NOFAILAUD)	/* 0x10 */
#define CHP$M_NOSUCCAUD (1<<CHP$V_NOSUCCAUD)	/* 0x20 */
#define CHP$M_DELETE	(1<<CHP$V_DELETE)	/* 0x40 */
#define CHP$M_MANDATORY (1<<CHP$V_MANDATORY)	/* 0x80 */
#define CHP$M_FLUSH	(1<<CHP$V_FLUSH)	/* 0x0100 */
#define CHP$M_CREATE	(1<<CHP$V_CREATE)	/* 0x0200 */
#define CHP$M_INTERNAL	(1<<CHP$V_INTERNAL)	/* 0x0400 */
#define CHP$M_SERVER	(1<<CHP$V_SERVER)	/* 0x0800 */
union chp$flag_bits {
    struct {
	unsigned chp$v_observe	  : 1;	/* non-discretionary read access */
	unsigned chp$v_alter	  : 1;	/* non-discretionary write access */
	unsigned		  : 14;
    } chp$r_sevms_defs;
    struct {
	unsigned chp$v_read	  : 1;	/* non-discretionary read access */
	unsigned chp$v_write	  : 1;	/* non-discretionary write access */
	unsigned chp$v_usereadall : 1;	/* READALL privilege applies */
	unsigned chp$v_audit	  : 1;	/* access audit requested */
	unsigned chp$v_nofailaud  : 1;	/* do not perform failed access audit */
	unsigned chp$v_nosuccaud  : 1;	/* do not perform successful access audit */
	unsigned chp$v_delete	  : 1;	/* perform audit as delete event type */
	unsigned chp$v_mandatory  : 1;	/* perform mandatory audit */
	unsigned chp$v_flush	  : 1;	/* force buffer flush in AUDIT_SERVER */
	unsigned chp$v_create	  : 1;	/* perform audit as create event type */
	unsigned chp$v_internal   : 1;	/* audit on behalf of VMS TCB */
	unsigned chp$v_server	  : 1;	/* audit originates in TCB server process */
	unsigned		  : 4;
    } chp$r_vms_defs;
};
#define CHP$V_NOACCESS	0
#define CHP$V_REMDUPID	1
#define CHP$V_INCSYSID	2
#define CHP$V_INCIMGID	3
#define CHP$V_DEFPRIV	4
#define CHP$V_DEFCLASS	5
#define CHP$M_NOACCESS	(1<<CHP$V_NOACCESS)	/* 0x01 */
#define CHP$M_REMDUPID	(1<<CHP$V_REMDUPID)	/* 0x02 */
#define CHP$M_INCSYSID	(1<<CHP$V_INCSYSID)	/* 0x04 */
#define CHP$M_INCIMGID	(1<<CHP$V_INCIMGID)	/* 0x08 */
#define CHP$M_DEFPRIV	(1<<CHP$V_DEFPRIV)	/* 0x10 */
#define CHP$M_DEFCLASS	(1<<CHP$V_DEFCLASS)	/* 0x20 */
struct chp$profile_flags {
    unsigned chp$v_noaccess	: 1;	/* do not access UAF to build profile */
    unsigned chp$v_remdupid	: 1;	/* remove duplicate system rights IDs */
    unsigned chp$v_incsysid	: 1;	/* include system rights IDs */
    unsigned chp$v_incimgid	: 1;	/* include image rights IDs */
    unsigned chp$v_defpriv	: 1;	/* initialize privs from default mask */
    unsigned chp$v_defclass	: 1;	/* initialize class from default mask */
    unsigned			: 2;
};

#endif	/*_CHPDEF_H*/
