/* 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_rmapi.h                                                  */
/*                                                                           */
/* Description:                                                              */
/*      Include for Event Management resource monitor api (librmapi.a)       */
/*                                                                           */
/*===========================================================================*/
/* sccsid = "@(#)38   1.18   src/rsct/pem/emcommon/ha_rmapi.h, emcommon, rsct_rady, rady2035a 2/13/19 17:05:20" */

#ifndef _H_HA_RMAPI
#define _H_HA_RMAPI

#include <ha_emcommon.h>

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


/*******************************************************************************
 *
 * Good and Bad return codes
 *
 ******************************************************************************/

#define HA_RR_PASS			(int)0
#define HA_RR_FAIL			(int)-1

/*******************************************************************************
 *
 * RMAPI error codes
 *
 * A '+' in the description indicates the error may be returned in either a
 * ha_em_err_blk structure, or in the rr_var_errno field of a ha_rr_variable
 * structure.        
 *
 ******************************************************************************/

#define HA_RR_ENOSDR			(int)101  /* SDR session subroutine failed    */
#define HA_RR_EACCESS			(int)102  /* Unable to open or create file    */	
#define HA_RR_EBADCDB			(int)103  /* EMCDB corrupted or back level    */
#define HA_RR_ESPMIFAIL			(int)104  /* libSpmi.a subroutine failed      */
#define HA_RR_ENOTSERVER		(int)105  /* Calling RM is not a server       */
#define HA_RR_ENOHNDLR			(int)106  /* No signal handler for SIGIO      */
#define HA_RR_ENOSERVSOCK		(int)107  /* RM server socket not created     */
#define HA_RR_EBADPROTO			(int)108  /* Bad or mismatched notify potocol */ 
#define HA_RR_EEXIST			(int)109  /* Socket already exists            */
#define HA_RR_EAGAIN			(int)110  /* No data or connection pending    */
#define HA_RR_EMAXSESSIONS		(int)111  /* HA_RR_MAX_SESSIONS reached       */
#define HA_RR_EBADSESSION		(int)112  /* Specified session not found      */
#define HA_RR_EDISCONNECT		(int)113  /* Session connection closed        */
#define HA_RR_ENOENT			(int)114  /* + Specified entity not in EMCDB  */
#define HA_RR_EBADRIDNAME		(int)115  /* + Bad resource ID name           */
#define HA_RR_ENORIDNAME		(int)116  /* + Missing resource ID element(s) */
#define HA_RR_EBADRSRCID		(int)117  /* + Bad resource ID element value  */
#define HA_RR_EDUPRSRCID		(int)118  /* + Duplicate resource ID element  */
#define HA_RR_EBADCLASS			(int)119  /* Resource class not found         */
#define HA_RR_ESYSCALL			(int)120  /* A system call failed             */
#define HA_RR_ENOMEM			(int)121  /* Memory allocation failed         */
#define HA_RR_EINTERNAL			(int)122  /* Internal RMAPI error occured     */
#define HA_RR_EPARM				(int)123  /* Bad parameter passed to RMAPI    */
#define HA_RR_EHADDR 			(int)124  /* + Bad handle location            */
#define HA_RR_EHANDLE			(int)125  /* + Handle value not valid         */
#define HA_RR_ENOTREG			(int)126  /* + Variable was not registered    */
#define HA_RR_EDUPREG			(int)127  /* + ID changed on subsequent reg   */
#define HA_RR_EGETNODNUM		(int)128  /* Unable to determine node number  */
#define HA_RR_ESDRGET			(int)129  /* SDRGet subroutine failed         */
#define HA_RR_EDOMAIN			(int)130  /* Error determining domain name    */
#define HA_RR_ENOVALUE			(int)131  /* + RV value address was NULL      */
#define HA_RR_ESBSLEN			(int)132  /* + Bad SBS value length           */
#define HA_RR_EBAD_SBSSN		(int)133  /* + Bad SBS field serial number    */
#define HA_RR_EDUP_SBSFIELD		(int)134  /* + Duplicate SBS field in value   */
#define HA_RR_EBAD_SBSFIELDTYPE	(int)135  /* + Bad SBS field type             */
#define HA_RR_EBAD_SBSFIELDLEN	(int)136  /* + Bad SBS field value length     */ 
#define HA_RR_EMISSING_SBSFIELD	(int)137  /* + SBS field(s) missing in value  */
#define HA_RR_EPERM				(int)138  /* Operation could not be performed */
#define HA_RR_ERMINSTID			(int)139  /* Monitor instance id not valid    */
#define HA_RR_EAPI_LOCKED		(int)140  /* RMAPI locked on previous error   */ 
#define HA_RR_ENAMETOOLONG		(int)141  /* File name/socket path too long   */
#define HA_RR_ENOCONNECT		(int)142  /* Error connecting to RMM          */
#define HA_RR_ESHM				(int)143  /* Bad private shm segment          */
#define HA_RR_EERRCMD			(int)144  /* RM error detected by manager     */
#define HA_RR_EAUTH				(int)145  /* No authority to use RMAPI        */
#define HA_RR_EINIT				(int)146  /* API already/not yet initialized  */
#define HA_RR_ECONNREFUSED		(int)147  /* Mgr not available for connect    */
#define HA_RR_ENOLOCK			(int)148  /* Unable to lock a RM instance     */
#define HA_RR_EBADMGRID			(int)149  /* Unknown resource monitor manager */

#define HA_RR_EBADVECNAME		HA_RR_EBADRIDNAME	/* For compatibility      */
#define HA_RR_ENOVECNAME		HA_RR_ENORIDNAME	/* For compatibility      */
#define HA_RR_EBADVECTOR		HA_RR_EBADRSRCID	/* For compatibility      */
#define HA_RR_EDUPVECTOR		HA_RR_EDUPRSRCID	/* For compatibility      */


/*******************************************************************************
 *
 * ctrl command values received from resource managers
 *
 ******************************************************************************/

#define HA_RR_CMD_ADDV			((int)0x00c9)	/* (int)201 */
#define HA_RR_CMD_ADDALL		((int)0x00ca)	/* (int)202 */
#define HA_RR_CMD_DELV			((int)0x00cb)	/* (int)203 */
#define HA_RR_CMD_DELALL		((int)0x00cc)	/* (int)204 */
#define HA_RR_CMD_REFRESH		((int)0x00cd)	/* (int)205 */
#define HA_RR_CMD_INSTV			((int)0x00ce)	/* (int)206 */
#define HA_RR_CMD_MGR_ID		((int)0x00cf)	/* (int)207 */
#define HA_RR_CMD_UNREG_ACK		((int)0x00d0)	/* (int)208 */
#define HA_RR_CMD_ATTCH_SHM		((int)0x00d1)	/* (int)209 */
#define HA_RR_CMD_ERROR         ((int)0x00d2)	/* (int)210 */
#define HA_RR_CMD_MGR_ID_EVM    ((int)0x01f5)	/* (int)501 */
#define HA_RR_CMD_MGR_ID_PERF   ((int)0x01f6)	/* (int)502 */

/*******************************************************************************
 *
 * Error codes returned in the rr_ctrl_cmdarg field if the command
 * is HA_RR_CMD_ERROR. (Only the header is sent).
 * These errors are processed by the RMAPI and are not returned to 
 * the resource monitor. 
 *
 ******************************************************************************/

#define HA_RR_CMD_ERROR_DUP     1
#define HA_RR_CMD_ERROR_ADD     2
#define HA_RR_CMD_ERROR_DEL     3
#define HA_RR_CMD_ERROR_BADRZ   4

/*******************************************************************************
 *
 * ctrl msg notification method HA_RR_NOTIFY_SELECT (for select or poll), 
 * HA_RR_NOTIFY_SIGIO for SIGIO signal notification
 * HA_RR_MAX_SESSIONS is the max number of client sessions for server RMs
 *
 ******************************************************************************/

#define HA_RR_NOTIFY_SELECT	(int)301
#define HA_RR_NOTIFY_SIGIO	(int)302
#define HA_RR_MAX_SESSIONS	(int)8

/*******************************************************************************
 *
 * Resource monitor instance id values.
 *
 ******************************************************************************/
#define HA_RR_RM_INSTID_PERF        (int)0
#define HA_RR_RM_INSTID_NOPERF      (int)-1
#define HA_RR_RM_INSTID_ANY         (int)-2
#define HA_RR_RM_INSTID_DEFAULT     HA_RR_RM_INSTID_ANY
#define HA_RR_RM_INSTID_MAX         (HA_EM_MAX_RM_INSTS - 1)

/*******************************************************************************
 *
 * Commands for the ha_rr_rm_ctl() routine.
 *
 ******************************************************************************/
#define HA_RR_RM_ARGS_GET           (int)0x00000001
#define HA_RR_RM_ARGS_SET_INSTID    (int)0x00000002

/*******************************************************************************
 *
 * rmapi structures
 *
 ******************************************************************************/

struct ha_rr_args {
    int     rr_instance_id;
    char   *rr_domain_name;
    char    rr_reserved[56];
};

struct ha_rr_variable {
	char 	*rr_var_name;
	char 	*rr_var_rsrc_ID;
	union {	
		int		rr_var_inst_id;
		void	**rr_var_hndl;
	} rr_varu;	
#define rr_var_handle	rr_varu.rr_var_hndl	
#define rr_var_iid		rr_varu.rr_var_inst_id	
	void	*rr_value;
	int		rr_var_errno;
};

struct ha_rr_val {
	void	*rr_value;
	void	*rr_var_hndl;
};

struct ha_rr_ctrl_msg {
	int		rr_ctrl_msg_len;
	int		rr_ctrl_cmd;
	int		rr_ctrl_cmdarg;
	int		rr_ctrl_num_vars;
	union	ha_rr_ctrlv {	
		struct ha_rr_ctrl_var {
			char	*rr_ctrl_name;
			char	*rr_ctrl_rsrc_ID;
		} rr_ctrl_varn[1];
		int rr_ctrl_vari[1];
		struct ha_rr_ctrl_var2 {
			int 	rr_ctrl_var_id;
			int 	rr_ctrl_API_inst_id;
		} rr_ctrl_varn2[1];
	} rr_ctrlv;
#define rr_ctrl_vars	rr_ctrlv.rr_ctrl_varn
#define rr_ctrl_ids		rr_ctrlv.rr_ctrl_vari
#define rr_ctrl_vars2	rr_ctrlv.rr_ctrl_varn2
};

/*******************************************************************************
 * Resource Monitor API compatibility definitions.
 *
 * These definitions are provided to maintain source compatibility with
 * programs written using prior versions of this header file.
 * If these definitions result in inappropriate substitutions, then define
 * the symbol HA_EM_NO_NAME_COMPAT prior to inclusion of this header file.
 * If HA_EM_NO_NAME_COMPAT is defined, the source files that include this
 * header file must be modified to use the new symbol names if the old
 * symbol names are referenced therein.
 ******************************************************************************/

#ifndef HA_EM_NO_NAME_COMPAT
#ifndef rr_var_ivector
#define rr_var_ivector rr_var_rsrc_ID
						/* replace rr_var_ivector by rr_var_rsrc_ID     */
#endif
#ifndef rr_ctrl_ivector
#define rr_ctrl_ivector rr_ctrl_rsrc_ID
						/* replace rr_ctrl_ivector by rr_ctrl_rsrc_ID   */
#endif
#endif	/* HA_EM_NO_NAME_COMPAT */
/*******************************************************************************
 *
 * rmapi function prototypes
 *
 ******************************************************************************/

#ifdef _NO_PROTO
int ha_rr_rm_ctl();
int ha_rr_init();
int ha_rr_makserv();
int ha_rr_start_session();
int ha_rr_get_ctrlmsg();
int ha_rr_end_session();
int ha_rr_add_var();
int ha_rr_del_var();
int ha_rr_get_interval();
int ha_rr_send_val();
int ha_rr_reg_var();
int ha_rr_unreg_var();
int ha_rr_terminate();
int ha_rr_touch();
#else	/* NO_PROTO */
int ha_rr_rm_ctl(struct ha_rr_args *, int, struct ha_em_err_blk *);
int ha_rr_init(char *, struct ha_em_err_blk *);
int ha_rr_makserv(int, struct ha_em_err_blk *);
int ha_rr_start_session(int, struct ha_em_err_blk *);
int ha_rr_get_ctrlmsg(int, struct ha_rr_ctrl_msg **, struct ha_em_err_blk *);
int ha_rr_end_session(int, struct ha_em_err_blk *);
int ha_rr_add_var(int, struct ha_rr_variable *, int, int, struct ha_em_err_blk *);
int ha_rr_del_var(int, struct ha_rr_variable *, int, struct ha_em_err_blk *);
int ha_rr_get_interval(char *, struct ha_em_err_blk *);
int ha_rr_send_val(struct ha_rr_val *pv, int, int, struct ha_em_err_blk *);
int ha_rr_reg_var(struct ha_rr_variable *, int, struct ha_em_err_blk *);
int ha_rr_unreg_var(struct ha_rr_variable *, int, struct ha_em_err_blk *);
int ha_rr_terminate(struct ha_em_err_blk *);
int ha_rr_touch(struct ha_em_err_blk *);
#endif		/* NO_PROTO */


#ifdef __cplusplus
}
#endif /* __cplusplus */


#endif		/* _H_HA_RMAPI */