/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/*                                                                        */
/*                                                                        */
/* Licensed Materials - Property of IBM                                   */
/*                                                                        */
/* (C) COPYRIGHT International Business Machines Corp. 1996,2019          */
/* 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                                                     */

/*===========================================================================*/
/*                                                                           */
/* Module Name:  ha_emcommon.h                                               */
/*                                                                           */
/* Description:                                                              */
/*     Common definitions for the Event Management Subsystem                 */
/*                                                                           */
/*===========================================================================*/

/* sccsid = "@(#)37   1.14   src/rsct/pem/emcommon/ha_emcommon.h, emcommon, rsct_rady, rady2035a 2/13/19 17:05:18" */

#ifndef _HA_EMCOMMON_H
#define _HA_EMCOMMON_H

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

#define HA_EM_MAXERRMSG  256
#define HA_EM_MAXERRLVL  16
#define HA_EM_MAXERRFN   32

struct ha_em_err_blk {
	int     em_errline;
	char    em_errlevel[HA_EM_MAXERRLVL];
	char    em_errfile[HA_EM_MAXERRFN];
	int     em_errno;
	char    em_errmsg[HA_EM_MAXERRMSG];
};

#define HA_EM_CLEAR_ERR(X)        memset(X,0,sizeof(struct ha_em_err_blk))

#define HA_EM_RSRC_ID_SIZE		4		/* max number of elements in a
										   resource ID */
#define HA_EM_VECTOR_SIZE		HA_EM_RSRC_ID_SIZE	/* for compatibility */

/* Max length of a resource ID value including null */
#define HA_EM_RSRC_ID_ELEM_VALUE_LEN_MAX		32
#define HA_EM_VECTOR_ELEM_VALUE_LEN_MAX		HA_EM_RSRC_ID_ELEM_VALUE_LEN_MAX

/* Max length of a Structured Byte String (including length field) */
#define HA_EM_MAX_SBS_VALUE_LEN         2048

/* Max number of variable instances accepted per class from RM */
#define HA_EM_MAX_INSTS			10000

enum ha_emValue_Type {
	ha_emVTcounter,
	ha_emVTquantity,
	ha_emVTstate
};

enum ha_emData_Type {
	ha_emDTlong,
	ha_emDTfloat,
	ha_emDTsbs
};

enum ha_emField_Type {
	ha_emFTlong,
	ha_emFTfloat,
	ha_emFTchar,
	ha_emFTbyte
};

enum ha_emElement_Type {
	ha_emETint,
	ha_emETstring
};

/* define pathnames for lock, socket, log and config files */

/* Define type and macros used to manage a resource monitor lock file.
 * This lock file is used to track a number of instances of the same
 * resource monitor program.
 *
 * ha_em_lckreg_t is the region of the file that is locked. 
 * HA_EM_MAX_RM_INSTS limits the number of instances of a resource monitor
 * and, hence, the number of lock regions.
 * In HA_EM_RM_LOCK_FMT, first %s is resource monitor name, second %s
 * is domain name.
 */
typedef int ha_em_lckreg_t;
#define HA_EM_RM_LOCK_FMT		"/var/ha/lck/haem/em.RM%s.%s"
#define HA_EM_MAX_RM_INSTS		8
#define HA_EM_LCK_SIZE			(sizeof(ha_em_lckreg_t))

/* file used in creation of key file, which holds the shared memory ID of
 * a shared memory segment used by a resource monitor instance and the
 * EM daemon. "Conceptually" a lock file, so put it in lck directory. First
 * %s is resource monitor name, %d is resource monitor instance number and
 * the last %s is the domain name.
 */
#define HA_EM_RMSHM_KEY_FMT		"/var/ha/lck/em.RM%s.%dSHM.%s"

/* Define macros useful in finding old key files from prior incarnations of
 * the EM daemon. The %s is the domain name.
 */
#define HA_EM_RMSHM_KEY_DIR_FMT		"/var/ha/lck"
#define HA_EM_RMSHM_KEY_PFX_FMT		"em.RM"
#define HA_EM_RMSHM_KEY_SFX_FMT		"SHM.%s"

/* name of file used to dump the red zone of a shared memory segment.
 * The red zone page is dumped when it is modified unexpectedly. The %s
 * is a resource monitor name, the first %d is a resource monitor instance
 * number and the last %d is a timestamp (in seconds).
 */
#define HA_EMRMSHM_RZ_FMT			"rzdump.RM%s.%d.%d"

/* file passed as argument to SPMI routines by the RMAPI. The %s is a
 * resource monitor name.
 */
#define HA_EM_SPMI_KEY_FMT			"/var/ha/lck/em.RM%sSPMI"

/* lock file to ensure single instance of an event management daemon.
 * %s is domain name.
 */
#define HA_EM_DAEMON_LOCK_FMT	"/var/ha/lck/em.haemd.%s"

/* name of Unix domain socket used by EMAPI to connect to event management
 * daemon. %s is domain name.
 */
#define HA_EM_CL_TO_D_SOCK_FMT	"/var/ha/soc/em.clsrv.%s"

/* name of Unix domain socket used by RMAPI to connect to event management
 * daemon. %s is domain name.
 */
#define HA_EM_RM_TO_D_SOCK_FMT	"/var/ha/soc/em.rmsrv.%s"

/* name of Unix domain socket used by event management daemon to connect to
 * a server resource monitor instance. First %s is resource monitor name,
 * the %d is a resource monitor instance number and the last %s is a domain
 * name.
 */
#define HA_EM_D_TO_RM_SOCK_FMT	"/var/ha/soc/haem/em.RM%s.%d.%s"

/* name of event management daemon log file for tracing. %s is domain
 * name.
 */
#define HA_EM_HAEMD_TRACE_LOG_FMT	"/var/ha/log/em.trace.%s"

/* name of event management daemon log file for tracing messages between the
 * various daemon components. %s is domain name.
 */
#define HA_EM_HAEMD_MSGTRACE_LOG_FMT	"/var/ha/log/em.msgtrace.%s"

/* name of event management daemon log file for default messages. These are
 * messages produced before logging to error log is possible. %s is domain
 * name.
 */
#define HA_EM_HAEMD_DFLT_LOG_FMT	"/var/ha/log/em.default.%s"

/* name of event management configuration data base. %s is domain name. */
#define HA_EM_HAEMD_CFGDB_FMT	"/etc/ha/cfg/em.%s.cdb"

/* name of file that contains the version string of the CDB currently 
 * being used by the event management daemon. This is used by the RMAPI
 * to insure it is using the same copy. %s is domain name.
 */
#define HA_EM_HAEMD_CFGDB_VERS_FMT   "/etc/ha/cfg/em.%s.cdb_vers"

/* name of directory where event management instance executes; place where
 * core files are produced. %s is domain name.
 */
#define HA_EM_HAEMD_CWD_FMT		"/var/ha/run/haem.%s"

/* define the service name for the port used by Event Management for peer
 * communication. %s is domain name.
 */
#define HA_EM_SERVICE_NAME_FMT		"haem.%s"

/*
 * Expression parsing and evaluation errors.
 */

#define HA_EM_EXPR_ERVAR        	1	/* Internal resource variable error. */
#define HA_EM_EXPR_EEXPRLEN     	2	/* Parsing table overflow.           */
#define HA_EM_EXPR_ESYNTAX      	3	/* Error in expression syntax.       */
#define HA_EM_EXPR_ESTACK       	4	/* Internal stack overflow.          */
#define HA_EM_EXPR_EILLEGALOP   	5	/* Illegal operation between types.  */
#define HA_EM_EXPR_ESTRING      	6	/* Error in string constant syntax.  */
#define HA_EM_EXPR_ESBSSN       	7	/* SBS out of range or missing from  */
										/*   value.                          */
#define HA_EM_EXPR_EFIELDTYPE   	8	/* Illegal or mismatch in SBS field  */
										/*   type.                           */
#define HA_EM_EXPR_EDATATYPE    	9	/* Invalid internal data type.       */
#define HA_EM_EXPR_ESBSLEN      	10	/* Mismatch SBS data type and field  */
										/*   length.                         */
#define HA_EM_EXPR_EDIVIDE      	11	/* Divide by zero.                   */
#define HA_EM_EXPR_EOCTAL_INVALID   12  /* Octal value was not valid.        */
#define HA_EM_EXPR_EOCTAL_2BIG      13  /* Octal value was > maximum allowed */

#define HA_EM_PRED_ERVAR        	HA_EM_EXPR_ERVAR          /* for compat */
#define HA_EM_PRED_EPREDLEN     	HA_EM_EXPR_EEXPRLEN       /* for compat */
#define HA_EM_PRED_ESYNTAX      	HA_EM_EXPR_ESYNTAX        /* for compat */
#define HA_EM_PRED_ESTACK       	HA_EM_EXPR_ESTACK         /* for compat */
#define HA_EM_PRED_EILLEGALOP   	HA_EM_EXPR_EILLEGALOP     /* for compat */
#define HA_EM_PRED_ESTRING      	HA_EM_EXPR_ESTRING        /* for compat */
#define HA_EM_PRED_ESBSSN       	HA_EM_EXPR_ESBSSN         /* for compat */
#define HA_EM_PRED_EFIELDTYPE   	HA_EM_EXPR_EFIELDTYPE     /* for compat */
#define HA_EM_PRED_EDATATYPE    	HA_EM_EXPR_EDATATYPE      /* for compat */
#define HA_EM_PRED_ESBSLEN      	HA_EM_EXPR_ESBSLEN        /* for compat */
#define HA_EM_PRED_EDIVIDE      	HA_EM_EXPR_EDIVIDE        /* for compat */
#define HA_EM_PRED_EOCTAL_INVALID   HA_EM_EXPR_EOCTAL_INVALID /* for compat */
#define HA_EM_PRED_EOCTAL_2BIG      HA_EM_EXPR_EOCTAL_2BIG    /* for compat */


#ifdef __cplusplus
}
#endif /* __cplusplus */


#endif	/* _HA_EMCOMMON_H */
