/* 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                                                     */
#ifndef _HA_GS_H_
#define _HA_GS_H_

static const char *ha_gs_h_sccsid = "@(#)86   1.131   src/rsct/pgs/pgslib/ha_gs.h, gsapi, rsct_rady, rady2035a 7/12/19 17:23:53";

#include <inttypes.h>
#include <sys/types.h>
#include <rsct/ct_ffdc.h>
#include <netinet/in.h>
#include <string.h>
#include <stdlib.h>

#ifdef __cplusplus
extern "C" {
#endif

#define HA_GS_RELEASE  			31   /* 3.2.5.0 */


typedef enum
{
    HA_GS_OK,                              /* 0 */
    HA_GS_OK_SO_FAR = HA_GS_OK,            /* 0 */
    HA_GS_NOT_OK                            =  1,
    HA_GS_EXISTS                            =  2,
    HA_GS_NO_INIT                           =  3,
    HA_GS_NAME_TOO_LONG                     =  4,
    HA_GS_NO_MEMORY                         =  5,
    HA_GS_NOT_A_MEMBER                      =  6,
    HA_GS_BAD_CLIENT_TOKEN                  =  7,
    HA_GS_BAD_MEMBER_TOKEN                  =  8,
    HA_GS_BAD_PARAMETER                     =  9,
    HA_GS_UNKNOWN_GROUP                     = 10,
    HA_GS_INVALID_GROUP                     = 11,
    HA_GS_NO_SOURCE_GROUP_PROVIDER          = 12,
    HA_GS_BAD_GROUP_ATTRIBUTES              = 13,
    HA_GS_WRONG_OLD_STATE                   = 14,
    HA_GS_DUPLICATE_INSTANCE_NUMBER         = 15,
    HA_GS_COLLIDE                           = 16,
    HA_GS_SOCK_CREATE_FAILED                = 17,
    HA_GS_SOCK_INIT_FAILED                  = 18,
    HA_GS_CONNECT_FAILED                    = 19,
    HA_GS_VOTE_NOT_EXPECTED                 = 20,
    HA_GS_NOT_SUPPORTED                     = 21,
    HA_GS_INVALID_SOURCE_GROUP              = 22,
    HA_GS_UNKNOWN_PROVIDER                  = 23,
    HA_GS_INVALID_DEACTIVATE_PHASE          = 24,
    HA_GS_PROVIDER_APPEARS_TWICE            = 25,
    HA_GS_BACKLEVEL_PROVIDERS               = 26,
    HA_GS_NULL_ADAPTER_INFO                 = 27,
    HA_GS_ADAPTER_INFO_NOT_FOUND            = 28,
    HA_GS_ADAPTER_INFO_NOT_SENT             = 29,
    HA_GS_NOT_ADAPTER_GROUP                 = 30,
    HA_GS_VOTE_VALUE_NOT_ALLOWED            = 31,
    HA_GS_BAD_INPUT_IP_FORMAT               = 32,
    HA_GS_NO_IPV4_ADDRESS_FOR_THE_ID        = 33,
    HA_GS_WRITE_SOCK_ERROR                  = 34,
    HA_GS_BAD_QUORUM_MSG_SEQNUM             = 35,
    HA_GS_NOT_REGISTERED_FOR_SYNC_QUORUM    = 36,
    HA_GS_UNEXPECTED_QUORUM_RESP            = 37,

#if 0 /* RESERVED -  NOT_SUPPORTED_YET (_USE_DEDICATED_THREAD_MODEL) */
    HA_GS_NO_DEDICATED_THREAD_MODEL         = 38,
    HA_GS_PIPE_CREATION_ERROR               = 39,
    HA_GS_EMPTY_TOKENSET                    = 40,
    HA_GS_INVALID_TOKENSET                  = 41,
    HA_GS_TOKENSET_NOT_FOUND                = 42,
    HA_GS_TOKEN_EXISTS                      = 43,
    HA_GS_TOKEN_NOT_FOUND                   = 44,
    HA_GS_MEMBER_OF_CATCHALL_TOKENSET       = 45,
#endif

    HA_GS_LAST_RESERVED_RC                  = 9999

} ha_gs_rc_t;			/* Return Codes */


typedef enum
{
    HA_GS_NO_BATCHING		= 0x0000,
    HA_GS_BATCH_JOINS		= 0x0001,
    HA_GS_BATCH_LEAVES		= 0x0002,
    HA_GS_BATCH_BOTH		= HA_GS_BATCH_JOINS|HA_GS_BATCH_LEAVES, /*0x0003*/
    HA_GS_DEACTIVATE_ON_FAILURE = 0x0004,
    HA_GS_COLLECT_VOTE_RESULT   = 0x0008, /* collect only vote list */
    HA_GS_COLLECT_MSG_RESULT    = 0x0010, /* collect only msg list */
    HA_GS_COLLECT_STATEVALUE_RESULT   = 0x0020,/*collect only state value list*/
    HA_GS_COLLECT_ALL_RESULT    = HA_GS_COLLECT_VOTE_RESULT|HA_GS_COLLECT_MSG_RESULT|HA_GS_COLLECT_STATEVALUE_RESULT /* collect all lists */
} ha_gs_batch_ctrl_t;		/* Controls Batching of Requests */

typedef enum
{
    HA_GS_1_PHASE		= 0x0001,
    HA_GS_N_PHASE		= 0x0002
} ha_gs_num_phases_t;		/* Protocol number of Phases selection */

typedef enum
{
    HA_GS_FIRST_MERGE_TYPE, 			   /* 0 */
    HA_GS_DISSOLVE_MERGE = HA_GS_FIRST_MERGE_TYPE, /* 0 */
    HA_GS_LARGER_MERGE,                            /* 1 */
    HA_GS_SMALLER_MERGE,                           /* 2 */
    HA_GS_DONTCARE_MERGE,                          /* 3 */
    HA_GS_ANYORDER_MERGE,                          /* 4 */
    HA_GS_LAST_MERGE_TYPE = HA_GS_ANYORDER_MERGE
} ha_gs_merge_ctrl_t;		/* Controlling Merges */

typedef enum
{
    HA_GS_NULL_VOTE                        = 0x00,
    HA_GS_VOTE_APPROVE                     = 0x01,
    HA_GS_VOTE_CONTINUE                    = 0x02,
    HA_GS_VOTE_REJECT                      = 0x03,
    /* The following values are only meaningful for the merge protocol */
    HA_GS_VOTE_APPROVE_AND_SWITCH_ALPHA_OMEGA  = 0x81,
    HA_GS_VOTE_CONTINUE_AND_SWITCH_ALPHA_OMEGA = 0x82
} ha_gs_vote_value_t;           /* Allowable Vote Responses */

typedef enum
{
    HA_GS_SOCKET_NO_SIGNAL		= 0x0000000,
    HA_GS_SOCKET_SIGNAL			= 0x00000001,  /* not supported */
    HA_GS_ENABLE_ADAPTER_INFO		= 0x00000002,
    HA_GS_ENABLE_DOMAIN_EVENT           = 0x00001000,  /* to receive domain events */
    HA_GS_ENABLE_IPV6                   = 0x00002000, /* enable IPv6 support */
    HA_GS_ENABLE_MIGRATION_CALLBACK     = 0x00004000, /* enable migrate to CAA callback */
    HA_GS_ENABLE_OPQUORUM_CALLBACK      = 0x00008000, /* enable Quorum Notification */
    HA_GS_ENABLE_OPQUORUM_ACK_REQUIRED  = 0x00010000, /* specified Quorum Ack  required*/
    HA_GS_ENABLE_TOKENSET_DISPATCH      = 0x00100000, /* dedicated thread dispatch model enabled */
    HA_GS_STREAM			= 0x00800000, /* reserved for IBM use for stream driver*/
    HA_GS_IMMEDIATE_DOMAIN_CONTROL	= 0x10000000  /* reserved for IBM use */
} ha_gs_socket_ctrl_t;		/* Socket Control */

typedef enum
{
    HA_GS_NON_BLOCKING,
    HA_GS_BLOCKING
} ha_gs_dispatch_flag_t;	/* Modify behavior of ha_gs_dispatch */

typedef enum
{
    HA_GS_RESPONSIVENESS_NOTIFICATION	= 0,
    HA_GS_QUERY_NOTIFICATION		= 1,
    HA_GS_DELAYED_ERROR_NOTIFICATION	= 2,
    HA_GS_N_PHASE_NOTIFICATION		= 3,
    HA_GS_APPROVED_NOTIFICATION		= 4,
    HA_GS_REJECTED_NOTIFICATION		= 5,
    HA_GS_ANNOUNCEMENT_NOTIFICATION	= 6,
    HA_GS_SUBSCRIPTION_NOTIFICATION	= 7,
    HA_GS_MERGE_NOTIFICATION		= 8,
    HA_GS_DOMAIN_NOTIFICATION           = 9,	
    HA_GS_NOTIFICATION_RESERVED_1 	= 99,
    HA_GS_NOTIFICATION_RESERVED_2 	= 100,
    HA_GS_NOTIFICATION_RESERVED_3 	= 101,
    HA_GS_NOTIFICATION_RESERVED_4 	= 102,
    HA_GS_NOTIFICATION_RESERVED_5 	= 103
} ha_gs_notification_type_t;            /* Identify types of notifications */

typedef enum
{
    HA_GS_RESPONSIVENESS		= 0,
    HA_GS_JOIN				= 1,
    HA_GS_FAILURE_LEAVE			= 2,
    HA_GS_LEAVE				= 3,
    HA_GS_EXPEL				= 4,
    HA_GS_STATE_VALUE_CHANGE		= 5,
    HA_GS_PROVIDER_MESSAGE		= 6,
    HA_GS_CAST_OUT			= 7,
    HA_GS_SOURCE_STATE_REFLECTION	= 8,
    HA_GS_MERGE				= 9,
    HA_GS_SUBSCRIPTION			= 10,
    HA_GS_GROUP_ATTRIBUTE_CHANGE	= 11,
    MAX_REQUEST = HA_GS_GROUP_ATTRIBUTE_CHANGE,	/* 11 */
    HA_GS_INTERNAL_REQUEST   = 99			/* internal request */
} ha_gs_request_t;		/* Type of request a notification was for */



/*
 *----------------------------------------------------------------------------
 * Note:
 * Responsiveness checks allow the Group Services subsystem to periodically 
 *   inspect the state of the GS client.
 *
 * The responsiveness type controls whether the client should be monitored,
 *   or what action should be taken in case of non-responsiveness.  In addition
 *   this type will determine whether the client should handled as a critical
 *   client.  The type will consist of three fields which can be OR-ed;
 *   "protocol", "action", and  "critical".
 *
 * The "Responsiveness protocol": Only of them can be selected.
 *    HA_GS_NO_RESPONSIVENESS
 *    HA_GS_PING_RESPONSIVENESS
 *    HA_GS_COUNTER_RESPONSIVENESS  - not supported at this moment.
 *
 * The "Action" for the non-responsive client: They can be OR-ed.
 *    HA_GS_KEEP_CHECK_RESPONSIVENESS
 *       This flag will make the responsiveness msgs to always be sent
 *       to the client even if the client is running a protocol (In default, 
 *       responsiveness msg will be only exchanged when the client is idle).
 *       Also note that this flag will work properly only under multi-threaded
 *       with dedicated ha_gs_dispatch() threads.
 *
 *    HA_GS_ANNOUNCEMENT_WHEN_SLOW
 *       The other providers will be notified if one of them is not responding.
 *       If no other option (e.g., script) is selected, this flag will be assumed.
 *
 *    HA_GS_EXEC_SCRIPT_WHEN_SLOW
 *       A script will be invoked when the corresponing client is not responding.
 *
 *   HA_GS_DAEMON_MUST_DIE_WHEN_SLOW
 *       This flag is reserved for IBM use.
 *       This flag will also be sliently ignored to the other clients.
 *
 * The "Critical" indicator:
 *    HA_GS_CRITICAL_CLIENT
 *       This flag is set when a client is critical and needs special handling.
 *    
 *----------------------------------------------------------------------------
 */

typedef enum
{
    /* responsiveness protocol type */
    HA_GS_NO_RESPONSIVENESS		= 0x00000000,
    HA_GS_PING_RESPONSIVENESS		= 0x00000001,
    HA_GS_COUNTER_RESPONSIVENESS	= 0x00000002,	/* not supported at this moment */

    /* responsiveness critical client */
    HA_GS_CRITICAL_CLIENT               = 0x00008000,

    /* responsiveness action type */
    HA_GS_KEEP_CHECK_RESPONSIVENESS	= 0x00010000,
    HA_GS_ANNOUNCEMENT_WHEN_SLOW	= 0x01000000,	/* default */
    HA_GS_EXEC_SCRIPT_WHEN_SLOW		= 0x02000000,
    HA_GS_DAEMON_MUST_DIE_WHEN_SLOW	= 0x04000000,   /* reserved for IBM use */
    HA_GS_CLOSE_CLIENT_SOCKET           = 0x08000000,    /* close the socket if not responding */
    HA_GS_KILL_CLIENT_WHEN_SLOW         = 0x10000000    /* kill client if this bit is set */
} ha_gs_responsiveness_type_t;		/* Type of responsiveness checking */

typedef enum
{
    HA_GS_NO_CHANGE                     = 0x00000000, /* 0 */
    HA_GS_PROPOSED_MEMBERSHIP           = 0x00000001, /* 1 */
    HA_GS_ONGOING_MEMBERSHIP            = 0x00000002, /* 2 */
    HA_GS_PROPOSED_STATE_VALUE          = 0x00000004, /* 4 */
    HA_GS_ONGOING_STATE_VALUE           = 0x00000008, /* 8 */
    HA_GS_UPDATED_PROVIDER_MESSAGE      = 0x00000010, /* 16 */
    HA_GS_UPDATED_MEMBERSHIP            = 0x00000020, /* 32 */
    HA_GS_REJECTED_MEMBERSHIP           = 0x00000040, /* 64 */
    HA_GS_UPDATED_STATE_VALUE           = 0x00000080, /* 128 */
    HA_GS_REFLECTED_SOURCE_STATE_VALUE  = 0x00000100, /* 256 */
    HA_GS_EXPEL_INFORMATION             = 0x00000200, /* 512 */
    HA_GS_PROPOSED_GROUP_ATTRIBUTES     = 0x00000400, /* 1024 */
    HA_GS_ONGOING_GROUP_ATTRIBUTES      = 0x00000800, /* 2048 */
    HA_GS_UPDATED_GROUP_ATTRIBUTES      = 0x00001000, /* 4096 */
    HA_GS_REJECTED_GROUP_ATTRIBUTES     = 0x00002000, /* 8192 */
    HA_GS_CURRENT_STATE_VALUE           = 0x00004000, /* */
    HA_GS_MERGE_GROUP_INFO              = 0x00010000, /* merge info is reported */
    HA_GS_MERGE_ALPHA_OMEGA_SWITCHED     = 0x00020000
} ha_gs_updates_t;                                /* Whats Changed */

typedef enum
{
    HA_GS_EXPLICIT_APPROVE			= 0x00000001, /* 1 */
    HA_GS_EXPLICIT_REJECT			= 0x00000002, /* 2 */
    HA_GS_DEFAULT_APPROVE			= 0x00000004, /* 4 */
    HA_GS_DEFAULT_REJECT			= 0x00000008, /* 8 */
    HA_GS_TIME_LIMIT_EXCEEDED			= 0x00000010, /* 16 */
    HA_GS_PROVIDER_FAILED			= 0x00000020, /* 32 */
    HA_GS_RESPONSIVENESS_NO_RESPONSE		= 0x00000040, /* 64 */
    HA_GS_RESPONSIVENESS_RESPONSE		= 0x00000080, /* 128 */
    HA_GS_GROUP_DISSOLVED			= 0x00000100, /* 256 */
    HA_GS_GROUP_SERVICES_HAS_DIED_HORRIBLY	= 0x00000200, /* 512 */
    HA_GS_DEACTIVATE_UNSUCCESSFUL               = 0x00000400, /* 1024 */
    HA_GS_DEACTIVATE_TIME_LIMIT_EXCEEDED        = 0x00000800, /* 2048 */
    HA_GS_GROUP_ATTRIBUTES_CHANGED              = 0x00001000, /* 4096 */
    HA_GS_MEMBER_LEAVE_DUE_TO_LOCAL_SPLIT       = 0x00002000, /* 8192 */
    HA_GS_MEMBER_LEAVE_DUE_TO_REMOTE_SPLIT      = 0x00004000, /* 16384 */
    HA_GS_MEMBER_LEAVE_DUE_TO_LINK_DOWN         = 0x00008000, /* 32768 */
    HA_GS_MEMBER_LEAVE_DUE_TO_SHUTDOWN          = 0x00010000, /* 65536 */
    HA_GS_MEMBER_LEAVE_DUE_TO_STOP              = 0x00020000, /* 131072 */
    HA_GS_MEMBER_LEAVE_DUE_TO_FORCE_DOWN        = 0x00040000, /* 262144 */

    HA_GS_MIN_SUMMARY_CODE		= HA_GS_EXPLICIT_APPROVE,
    HA_GS_MAX_SUMMARY_CODE		= HA_GS_MEMBER_LEAVE_DUE_TO_FORCE_DOWN
} ha_gs_summary_code_t;		/* Notification summary */

typedef enum
{
    HA_GS_CALLBACK_NOT_OK,
    HA_GS_CALLBACK_OK
} ha_gs_callback_rc_t;		/* Callback Return Codes */

typedef enum
{
    HA_GS_FAILURE_NONE          = 0x0000, /* 0 */
    HA_GS_VOLUNTARY_LEAVE	= 0x0001, /* 1 */
    HA_GS_PROVIDER_FAILURE	= 0x0002, /* 2 */
    HA_GS_HOST_FAILURE		= 0x0004, /* 4 */
    HA_GS_PROVIDER_EXPELLED	= 0x0008, /* 8 */
    HA_GS_SOURCE_PROVIDER_LEAVE = 0x0010, /* 16 */
    HA_GS_PROVIDER_SAID_GOODBYE = 0x0020, /* 32 */
    HA_GS_NETWORK_SUNDERED      = 0x0040, /* 64 */
    HA_GS_HOST_LEAVE_DUE_TO_LOCAL_SPLIT  = 0x0080, /* 128 */
    HA_GS_HOST_LEAVE_DUE_TO_REMOTE_SPLIT = 0x0100, /* 256 */
    HA_GS_HOST_LEAVE_DUE_TO_LINK_DOWN  = 0x0200, /* 512 */
    HA_GS_HOST_LEAVE_DUE_TO_SHUTDOWN   = 0x0400, /* 1024 */
    HA_GS_HOST_LEAVE_DUE_TO_STOP       = 0x0800, /* 2048 */
    HA_GS_HOST_LEAVE_DUE_TO_FORCE_DOWN = 0x1000  /* 4096 */
} ha_gs_leave_reasons_t;

typedef enum
{
    HA_GS_QUERY_ALL,
    HA_GS_QUERY_GROUP
} ha_gs_query_type_t;

typedef enum
{
    HA_GS_SUBSCRIBE_STATE		= 0x01,
    HA_GS_SUBSCRIBE_DELTA_JOINS		= 0x02,
    HA_GS_SUBSCRIBE_DELTA_LEAVES	= 0x04,
    HA_GS_SUBSCRIBE_DELTAS_ONLY 	= 0x06,
    HA_GS_SUBSCRIBE_MEMBERSHIP  	= 0x08,
    HA_GS_SUBSCRIBE_ALL_MEMBERSHIP      = 0x0e,
    HA_GS_SUBSCRIBE_STATE_AND_MEMBERSHIP= 0x0f,
    HA_GS_SUBSCRIBE_ADAPTER_INFO        = 0x10,
    HA_GS_SUBSCRIBE_SPECIAL_DATA        = 0x40,
    HA_GS_SUBSCRIBE_PERSISTENCE         = 0x200
} ha_gs_subscription_ctrl_t;

typedef enum
{
    HA_GS_SUBSCRIPTION_STATE		= 0x01, /* 1 */
    HA_GS_SUBSCRIPTION_DELTA_JOIN	= 0x02, /* 2 */
    HA_GS_SUBSCRIPTION_DELTA_LEAVE	= 0x04, /* 4 */
    HA_GS_SUBSCRIPTION_MEMBERSHIP	= 0x08, /* 8 */
    HA_GS_SUBSCRIPTION_SPECIAL_DATA	= 0x40, /* 64 */
    HA_GS_SUBSCRIPTION_DISSOLVED	= 0x80, /* 128 */
    HA_GS_SUBSCRIPTION_GS_HAS_DIED      = 0x100, /* 256 */
    HA_GS_SUBSCRIPTION_PERSISTENT       = 0x200 
} ha_gs_subscription_type_t;

typedef enum {
    HA_GS_MIGRATION_VOTE_YES = 1,
    HA_GS_MIGRATION_VOTE_NO  = 2
} ha_gs_migration_vote_t;

typedef int ha_gs_token_t;
typedef int ha_gs_descriptor_t;
typedef unsigned short ha_gs_time_limit_t;

#define HA_GS_MAX_GROUP_NAME_LENGTH	32
typedef char *ha_gs_group_name_t;

/* Use this name to subscribe to processor membership. */
#define HA_GS_HOST_MEMBERSHIP_GROUP 	"HostMembership"

#define HA_GS_ENET_MEMBERSHIP_GROUP	"enMembership"
#define HA_GS_CSSRAW_MEMBERSHIP_GROUP	"cssRawMembership"
#define HA_GS_ML0_MEMBERSHIP_GROUP	"ml0Membership"
#define HA_GS_TOKENRING_MEMBERSHIP_GROUP "trMembership"
#define HA_GS_FDDI_MEMBERSHIP_GROUP	"fddiMembership"
#define HA_GS_RS232_MEMBERSHIP_GROUP	"rs232Membership"
#define HA_GS_TMSCSI_MEMBERSHIP_GROUP	"tmscsiMembership"
#define HA_GS_TMSSA_MEMBERSHIP_GROUP	"tmssaMembership"
#define HA_GS_SLIP_MEMBERSHIP_GROUP	"slipMembership"
#define HA_GS_ATM_MEMBERSHIP_GROUP	"atmMembership"
#define HA_GS_MYRINET_MEMBERSHIP_GROUP	"myriMembership"
#define HA_GS_FC_MEMBERSHIP_GROUP       "fcMembership"
#define HA_GS_BOND_MEMBERSHIP_GROUP       "bondMembership"
#define HA_GS_EIP_MEMBERSHIP_GROUP       "eipMembership"
#define HA_GS_ALL_ADAPTER_MEMBERSHIP_GROUP  "allAdapterMembership"

/* Use this name to subscribe to switch membership. */
#define HA_GS_CSS_MEMBERSHIP_GROUP	"cssMembership"
#define HA_GS_CSS0_MEMBERSHIP_GROUP	HA_GS_CSS_MEMBERSHIP_GROUP
#define HA_GS_CSS1_MEMBERSHIP_GROUP	"css1Membership"
#define HA_GS_CSS2_MEMBERSHIP_GROUP	"css2Membership"
#define HA_GS_CSS3_MEMBERSHIP_GROUP	"css3Membership"
#define HA_GS_CSS4_MEMBERSHIP_GROUP	"css4Membership"
#define HA_GS_CSS5_MEMBERSHIP_GROUP	"css5Membership"
#define HA_GS_CSS6_MEMBERSHIP_GROUP	"css6Membership"
#define HA_GS_CSS7_MEMBERSHIP_GROUP	"css7Membership"
#define HA_GS_CSS8_MEMBERSHIP_GROUP	"css8Membership"
#define HA_GS_CSSALL_MEMBERSHIP_GROUP	"cssAllMembership"

#define HA_GS_SWNET0_MEMBERSHIP_GROUP	HA_GS_CSS0_MEMBERSHIP_GROUP
#define HA_GS_SWNET1_MEMBERSHIP_GROUP	HA_GS_CSS1_MEMBERSHIP_GROUP
#define HA_GS_SWNET2_MEMBERSHIP_GROUP	HA_GS_CSS2_MEMBERSHIP_GROUP
#define HA_GS_SWNET3_MEMBERSHIP_GROUP	HA_GS_CSS3_MEMBERSHIP_GROUP
#define HA_GS_SWNET4_MEMBERSHIP_GROUP	HA_GS_CSS4_MEMBERSHIP_GROUP
#define HA_GS_SWNET5_MEMBERSHIP_GROUP	HA_GS_CSS5_MEMBERSHIP_GROUP
#define HA_GS_SWNET6_MEMBERSHIP_GROUP	HA_GS_CSS6_MEMBERSHIP_GROUP
#define HA_GS_SWNET7_MEMBERSHIP_GROUP	HA_GS_CSS7_MEMBERSHIP_GROUP
#define HA_GS_SWNET8_MEMBERSHIP_GROUP	HA_GS_CSS8_MEMBERSHIP_GROUP
#define HA_GS_SWNETALL_MEMBERSHIP_GROUP	HA_GS_CSSALL_MEMBERSHIP_GROUP

typedef struct
{
    short		gs_version;
    short		gs_sizeof_group_attributes;
    short		gs_client_version;
    ha_gs_batch_ctrl_t	gs_batch_control;
    ha_gs_num_phases_t	gs_num_phases;
    ha_gs_num_phases_t	gs_source_reflection_num_phases;
    ha_gs_vote_value_t	gs_group_default_vote;
    ha_gs_merge_ctrl_t	gs_merge_control;
    ha_gs_time_limit_t	gs_time_limit;
    ha_gs_time_limit_t	gs_source_reflection_time_limit;
    ha_gs_group_name_t	gs_group_name;
    ha_gs_group_name_t	gs_source_group_name;
    ha_gs_vote_value_t  gs_merge_default_vote; /* for merge */
} ha_gs_group_attributes_t;		/* Identify Group Attributes */

#ifdef __cplusplus
const   short   HA_GS_node_number = -1;
const   short   HA_GS_instance_number = -1;
#else
#define HA_GS_node_number	((short)-1)
#define HA_GS_instance_number	((short)-1)
#endif

#define gs_node_number _gs_provider_info._gs_node_number
#define gs_instance_number _gs_provider_info._gs_instance_number

typedef union
{
    struct
    {
        short	_gs_instance_number;
        short	_gs_node_number;
    } _gs_provider_info;
    int gs_provider_id;
} ha_gs_provider_t;			/* Provider ID */


typedef struct
{
    int		gs_length;
    char	*gs_state;
} ha_gs_state_value_t;		/* State Vector */

typedef struct
{
    short		gs_version;
    ha_gs_state_value_t	gs_group_state_value;
} ha_gs_group_state_t;		/* encapsulation of state vector */

typedef struct
{
    int		gs_length;
    char	*gs_message;
} ha_gs_provider_message_t;	/* provider message */

typedef struct
{
    ha_gs_responsiveness_type_t	gs_responsiveness_type;
    unsigned int		gs_responsiveness_interval;
    ha_gs_time_limit_t		gs_responsiveness_response_time_limit;
    void			*gs_counter_location;
    unsigned int		gs_counter_length;
} ha_gs_responsiveness_t;		/* responsiveness attributes */

typedef union
{
    struct {
	ha_gs_state_value_t	*_gs_info_state;
	ha_gs_provider_t	*_gs_info_providers;
    } _gs_group_info;
    ha_gs_group_name_t  _gs_groups;     /* renamed from 'gs_groups' */
#ifndef _KERNEL
    /* keep the old 'gs_groups' for the compatibility */
    #define gs_groups _gs_groups
#endif
} ha_gs_group_info_t;

#define gs_group_info_state     _gs_group_info._gs_info_state
#define gs_group_info_providers _gs_group_info._gs_info_providers

typedef struct
{
    ha_gs_query_type_t	gs_query_type;
    ha_gs_rc_t		gs_query_return_code;
    int			gs_number_of_groups;
    ha_gs_group_info_t	*gs_group_info;
} ha_gs_query_info_t;

typedef struct
{
    unsigned int 	gs_count;
    ha_gs_provider_t	*gs_providers;
} ha_gs_membership_t;		/* Membership List */

typedef struct {
    int			gs_deactivate_phase;
    int                 gs_expel_flag_length;
    char                *gs_expel_flag;
} ha_gs_expel_info_t;

typedef struct
{
    unsigned int	gs_voluntary_or_failure;
    unsigned int	gs_voluntary_leave_code;
} ha_gs_leave_info_t;

typedef struct
{
    unsigned int 	gs_count;
    ha_gs_leave_info_t	*gs_leave_codes;
} ha_gs_leave_array_t;

typedef struct {
    unsigned short	gs_num_phases;
    unsigned short	gs_phase_number;
} ha_gs_phase_info_t;

typedef struct {
    ha_gs_membership_t   *gs_alpha_providers;
    ha_gs_membership_t   *gs_omega_providers;
    ha_gs_group_state_t  gs_alpha_group_state;
    ha_gs_group_state_t  gs_omega_group_state;
} ha_gs_merge_info_t;

typedef struct
{
    ha_gs_provider_t        gs_voter;
    ha_gs_vote_value_t      gs_vote_value;
    ha_gs_summary_code_t    gs_summary_code;
    ha_gs_leave_reasons_t   gs_leave_code;
    ha_gs_state_value_t     *gs_proposed_state_value;
    ha_gs_provider_message_t *gs_provider_message;
} ha_gs_vote_result_t;

typedef ha_gs_vote_result_t    *ha_gs_vote_result_ptr_t;

typedef struct
{
    unsigned int               gs_count;
    ha_gs_vote_result_ptr_t    *gs_vote_results;
} ha_gs_vote_result_array_t;

typedef enum {
    HA_GS_ADAPTER_DEATH_ARRAY	= 0x01,
    HA_GS_CURRENT_ADAPTER_ALIAS_ARRAY 	= 0x02,
    HA_GS_CHANGING_ADAPTER_ALIAS_ARRAY 	= 0x04
} ha_gs_subscription_special_type_t;

typedef enum
{
    HA_GS_ADAPTER_DEAD		= 0x0001,
    HA_GS_ADAPTER_REMOVED	= 0x0002
} ha_gs_adapter_death_t;

typedef struct  {
    int                 gs_length;
    unsigned int        gs_flag;
    void                *gs_special_data;
} ha_gs_special_data_t;

typedef struct ha_gs_special_block_t {
    unsigned int        gs_special_flag;
    struct ha_gs_special_block_t        *gs_next_special_block;
    int			gs_special_num_entries;
    int			gs_special_length;
    void        	*gs_special;
} ha_gs_special_block_t;

/* maximum limits */
typedef struct {
    int max_provider_message_length;
    int max_state_value_length;
    int max_group_name_length;
} ha_gs_limits;

/* NOTE: at this moment, only IPv4 will be supported */

/* feature 150043: IPv6 support */
typedef union {
    struct {
        uint32_t        filler[3];
        struct in_addr  ip4x;
    }ipv4_in_6;
    struct in6_addr     ip6;
} ha_gs_ip_addr;

#define ip4   ipv4_in_6.ip4x

typedef struct {
    ha_gs_ip_addr              ip_addr;
    short                      node_number;
    const char                 *interface_name;
    ha_gs_provider_t           gs_member_id; /* not used yet */
    const char 		       *gs_group_name; /* not used yet */
    const char                 *hb_network_name;
    const char                 *hb_network_type;
    void                       *__reserved_1__; /* do not reference this variable */
    void                       *__reserved_2__; /* do not reference this variable */
} ha_gs_adapter_info;

typedef struct
{
    unsigned int       gs_count;
    ha_gs_ip_addr      *gs_ip_members;
} ha_gs_adapter_ip_membership_t;


typedef struct
{
    ha_gs_phase_info_t		gs_phase_info;
    ha_gs_provider_t		gs_proposed_by;
    ha_gs_updates_t		gs_whats_changed;
    ha_gs_membership_t		*gs_current_providers;
    ha_gs_membership_t		*gs_changing_providers;
    ha_gs_leave_array_t		*gs_leave_info;
    ha_gs_expel_info_t		*gs_expel_info;
    ha_gs_state_value_t		*gs_current_state_value;
    ha_gs_state_value_t		*gs_proposed_state_value;
    ha_gs_state_value_t		*gs_source_state_value;
    ha_gs_provider_message_t	*gs_provider_message;
    ha_gs_group_attributes_t    *gs_new_group_attributes;
    ha_gs_merge_info_t          *gs_merge_info;
    ha_gs_vote_result_array_t   *gs_current_vote_results;
    ha_gs_vote_result_array_t   *gs_changing_vote_results;
} ha_gs_proposal_t;

typedef struct
{
    ha_gs_notification_type_t	gs_notification_type;
    ha_gs_responsiveness_t      gs_responsiveness_information;
} ha_gs_responsiveness_notification_t;

typedef struct
{
    ha_gs_notification_type_t	gs_notification_type;
    unsigned int		gs_number_of_queries;
    ha_gs_query_info_t		*gs_query_info;
} ha_gs_query_notification_t;

typedef struct
{
    ha_gs_notification_type_t	gs_notification_type;
    ha_gs_token_t		gs_provider_token;
    ha_gs_request_t		gs_protocol_type;
    ha_gs_summary_code_t	gs_summary_code;
    ha_gs_time_limit_t		gs_time_limit;
    ha_gs_proposal_t		*gs_proposal;
    uint64_t                    gs_event_seqnum;
} ha_gs_n_phase_notification_t;

typedef struct
{
    ha_gs_notification_type_t	gs_notification_type;
    ha_gs_token_t		gs_provider_token;
    ha_gs_request_t		gs_protocol_type;
    ha_gs_summary_code_t	gs_summary_code;
    ha_gs_proposal_t		*gs_proposal;
    uint64_t                    gs_event_seqnum;
} ha_gs_approved_notification_t;

typedef struct
{
    ha_gs_notification_type_t	gs_notification_type;
    ha_gs_token_t		gs_provider_token;
    ha_gs_request_t		gs_protocol_type;
    ha_gs_summary_code_t	gs_summary_code;
    ha_gs_proposal_t		*gs_proposal;
    uint64_t                    gs_event_seqnum;
} ha_gs_rejected_notification_t;

typedef struct
{
    ha_gs_notification_type_t	gs_notification_type;
    ha_gs_token_t		gs_provider_token;
    ha_gs_summary_code_t	gs_summary_code;
    ha_gs_membership_t		*gs_announcement;
} ha_gs_announcement_notification_t;

typedef struct
{
    ha_gs_notification_type_t	gs_notification_type;
    ha_gs_token_t		gs_provider_token;
    ha_gs_request_t		gs_protocol_type;
    ha_gs_proposal_t		*gs_proposal;
    ha_gs_merge_ctrl_t		gs_merge_control;
    ha_gs_group_state_t		gs_alpha_group_state;
    ha_gs_group_state_t		gs_omega_group_state;
} ha_gs_merge_notification_t;

typedef struct
{
    ha_gs_notification_type_t	gs_notification_type;
    ha_gs_token_t		gs_subscriber_token;
    ha_gs_subscription_type_t	gs_subscription_type;
    ha_gs_state_value_t		*gs_state_value;
    ha_gs_membership_t		*gs_full_membership;
    ha_gs_membership_t		*gs_changing_membership;
    ha_gs_special_data_t        *gs_subscription_special_data;
    ha_gs_adapter_ip_membership_t  *gs_full_ip_membership;
    ha_gs_adapter_ip_membership_t  *gs_changing_ip_membership;
    ha_gs_adapter_death_t          *gs_reason_flags;
    ha_gs_merge_info_t             *gs_merge_info;
	ha_gs_leave_info_t             *gs_leave_codes;
    uint64_t                       gs_event_seqnum;
} ha_gs_subscription_notification_t;

/*
 *------------------------------------------------------------------
 *------------------------------------------------------------------
 */

typedef void (ha_gs_subscription_cb_t)(const ha_gs_subscription_notification_t*);

typedef void (ha_gs_query_cb_t)(const ha_gs_query_notification_t*);

typedef ha_gs_callback_rc_t (ha_gs_responsiveness_cb_t)(const ha_gs_responsiveness_notification_t*);

typedef void (ha_gs_n_phase_cb_t)(const ha_gs_n_phase_notification_t*);

typedef void (ha_gs_approved_cb_t)(const ha_gs_approved_notification_t*);

typedef void (ha_gs_rejected_cb_t)(const ha_gs_rejected_notification_t*);

typedef void (ha_gs_announcement_cb_t)(const ha_gs_announcement_notification_t*);

typedef void (ha_gs_merge_cb_t)(const ha_gs_merge_notification_t*);

typedef	struct {
    ha_gs_group_attributes_t	*gs_group_attributes;
    short       		gs_provider_instance;
    char			*gs_provider_local_name;
    ha_gs_n_phase_cb_t		*gs_n_phase_protocol_callback;
    ha_gs_approved_cb_t		*gs_protocol_approved_callback;
    ha_gs_rejected_cb_t		*gs_protocol_rejected_callback;
    ha_gs_announcement_cb_t	*gs_announcement_callback;
    ha_gs_merge_cb_t		*gs_merge_callback;
} ha_gs_join_request_t;

typedef struct {
    ha_gs_num_phases_t		gs_num_phases;
    ha_gs_time_limit_t		gs_time_limit;
    ha_gs_state_value_t		gs_new_state;
} ha_gs_state_change_request_t;

typedef	struct {
    ha_gs_num_phases_t		gs_num_phases;
    ha_gs_time_limit_t		gs_time_limit;
    ha_gs_provider_message_t	gs_message;
} ha_gs_message_request_t;

typedef struct {
    ha_gs_num_phases_t		gs_num_phases;
    ha_gs_time_limit_t		gs_time_limit;
    unsigned int		gs_leave_code;
} ha_gs_leave_request_t;

typedef	struct {
    ha_gs_num_phases_t		gs_num_phases;
    ha_gs_time_limit_t		gs_time_limit;
    ha_gs_membership_t		gs_expel_list;
    int         		gs_deactivate_phase;
    char                        *gs_deactivate_flag;
} ha_gs_expel_request_t;

typedef struct  {
    ha_gs_subscription_ctrl_t   gs_subscription_control;
    ha_gs_group_name_t          gs_subscription_group;
    ha_gs_subscription_cb_t     *gs_subscription_callback;
} ha_gs_subscribe_request_t;

typedef	struct {
    ha_gs_num_phases_t		gs_num_phases;
    ha_gs_time_limit_t		gs_time_limit;
    ha_gs_group_attributes_t	*gs_group_attributes;
    ha_gs_membership_t		*gs_backlevel_providers;
} ha_gs_attribute_change_request_t;

#define gs_join_request		_gs_protocol_info._gs_join_request
#define gs_state_change_request	_gs_protocol_info._gs_state_change_request
#define gs_message_request	_gs_protocol_info._gs_message_request
#define gs_leave_request	_gs_protocol_info._gs_leave_request
#define gs_expel_request	_gs_protocol_info._gs_expel_request
#define gs_subscribe_request	_gs_protocol_info._gs_subscribe_request
#define gs_attribute_change_request     _gs_protocol_info._gs_attribute_change_request

typedef struct {
    union {
    ha_gs_join_request_t		_gs_join_request;
    ha_gs_state_change_request_t	_gs_state_change_request;
    ha_gs_message_request_t		_gs_message_request;
    ha_gs_leave_request_t		_gs_leave_request;
    ha_gs_expel_request_t		_gs_expel_request;
    ha_gs_subscribe_request_t           _gs_subscribe_request;
    ha_gs_attribute_change_request_t    _gs_attribute_change_request;
    } 	_gs_protocol_info;
} ha_gs_proposal_info_t;

typedef struct
{
    ha_gs_notification_type_t	gs_notification_type;
    ha_gs_token_t		gs_request_token;
    ha_gs_request_t		gs_protocol_type;
    ha_gs_rc_t			gs_delayed_return_code;
    ha_gs_proposal_info_t	*gs_failing_request;
    ha_gs_group_attributes_t    *old_group_attributes;
} ha_gs_delayed_error_notification_t;

typedef void (ha_gs_delayed_error_cb_t)(const ha_gs_delayed_error_notification_t*);

/* The following macro is for the compatibility to the previous versions */
   ha_gs_rc_t ha_gs_setup(int compiled_version, int argcount, 
			ha_gs_descriptor_t *descriptor_addr,
                      const ha_gs_socket_ctrl_t socket_control,
                      const ha_gs_responsiveness_t *responsiveness_control,
                      const char *deactivate_script,
                      ha_gs_responsiveness_cb_t *responsiveness_cb_addr,
                      ha_gs_delayed_error_cb_t *delayed_error_cb_addr,
                      ha_gs_query_cb_t *query_cb_addr, ...);
#ifndef _HA_GS_BUILD_COMPATIBLE_FUNCTION_
   /* This section will always be included for the applications */
   #ifdef __cplusplus
       inline ha_gs_rc_t ha_gs_init(ha_gs_descriptor_t *descriptor_addr,
		      const ha_gs_socket_ctrl_t socket_control,
                      const ha_gs_responsiveness_t *responsiveness_control,
                      const char *deactivate_script,
                      ha_gs_responsiveness_cb_t *responsiveness_cb_addr,
                      ha_gs_delayed_error_cb_t *delayed_error_cb_addr,
                      ha_gs_query_cb_t *query_cb_addr)
        {
                return ha_gs_setup(HA_GS_RELEASE, 7,
                       descriptor_addr,
                       socket_control,
                       responsiveness_control,
                       deactivate_script,
                       responsiveness_cb_addr,
                       delayed_error_cb_addr,
                       query_cb_addr);
        }
  #else
     #define ha_gs_init(a,b,c,d,e,f,g) ha_gs_setup(HA_GS_RELEASE,7,a,b,c,d,e,f,g)
  #endif
#endif

ha_gs_rc_t ha_gs_get_node_number(int *node_number);
ha_gs_rc_t ha_gs_get_limits(ha_gs_limits *limits);
ha_gs_rc_t ha_gs_get_adapter_info(ha_gs_adapter_info *adapter);
ha_gs_rc_t ha_gs_get_adapter_info_by_addr(const ha_gs_ip_addr *ip, ha_gs_adapter_info *adapter);
ha_gs_rc_t ha_gs_get_adapter_info_by_id(ha_gs_token_t _subscriber_token, const ha_gs_provider_t *_id, ha_gs_adapter_info *adapter);

ha_gs_rc_t ha_gs_get_ipaddr_by_id(ha_gs_token_t _subscriber_token, const ha_gs_provider_t *_id, ha_gs_ip_addr *_ip);

/* to change the responsiveness parameter */
ha_gs_rc_t ha_gs_change_responsiveness(const ha_gs_responsiveness_t *resp);

ha_gs_rc_t ha_gs_dispatch(const ha_gs_dispatch_flag_t);
ha_gs_rc_t ha_gs_join(ha_gs_token_t *,
		      const ha_gs_proposal_info_t *);

ha_gs_rc_t ha_gs_change_state_value(ha_gs_token_t,
				    const ha_gs_proposal_info_t *);

ha_gs_rc_t ha_gs_send_message(ha_gs_token_t,
				       const ha_gs_proposal_info_t *);

ha_gs_rc_t ha_gs_leave(ha_gs_token_t,
		       const ha_gs_proposal_info_t *);

ha_gs_rc_t ha_gs_expel(ha_gs_token_t,
		       const ha_gs_proposal_info_t *);

ha_gs_rc_t ha_gs_change_attributes(ha_gs_token_t,
                                   const ha_gs_proposal_info_t *);

ha_gs_rc_t ha_gs_goodbye(ha_gs_token_t);

ha_gs_rc_t ha_gs_vote(ha_gs_token_t,
		      ha_gs_vote_value_t,
		      const ha_gs_state_value_t *,
		      const ha_gs_provider_message_t *,
		      ha_gs_vote_value_t);

ha_gs_rc_t ha_gs_quit(void);

ha_gs_rc_t ha_gs_query_group_list(void);

ha_gs_rc_t ha_gs_query_group_info(const ha_gs_group_name_t);

ha_gs_rc_t ha_gs_subscribe(ha_gs_token_t *,
                           const ha_gs_proposal_info_t *);

ha_gs_rc_t ha_gs_unsubscribe(ha_gs_token_t);

void    ha_gs_copy_group_attributes(ha_gs_group_attributes_t *gAttrsTarg,
                                    ha_gs_group_attributes_t *gAttrsSrc);

ha_gs_rc_t ha_gs_get_ffdc_id(fc_eid_t fcid);
/*
 *------------------------------------------------------------------
 * Domain Events Handling 
 *------------------------------------------------------------------
 */

/* Node identifier: only 'node_number' is used for now */
typedef struct
{
    int32_t            node_number;     /* -1 if not used */
    uint32_t           node_epoch;      /* reserved for the future use */
    uint64_t           node_id;         /* reserved for the future use */
} ha_gs_node_spec_t;

/* node membership */
typedef struct
{
    unsigned int         gs_count;
    ha_gs_node_spec_t    *gs_nodes;
} ha_gs_node_membership_t;           /* Node membership List */

/*
 * UUID - (opaque 128bit)
 */
typedef struct
{
    union
    {
    	uint64_t   bits64[2];
        unsigned char bytes[16];
    } val;
} ha_gs_uuid_t;


/*
 *---------------------------------------------------------------------------
 * The following domain/site event notifications can be notified.
 *  HA_GS_DOMAIN_DISCOVER  -- Internal use (Not be sent to other application)
 *  HA_GS_DOMAIN_MERGE     -- Internal use (Not be sent to other application)
 *  HA_GS_DOMAIN_VERSION   -- Whenever RSCT active/install version changes
 *  HA_GS_DOMAIN_NODE_CONFIG -- Whenever nodes are added/deleted
 *  HA_GS_MIGRATE_TO_CAA -- Migrate to CAA
 * Extension for Site split/merge handling
 *  HA_GS_SITE_SPLIT  -- when two sites are splitted
 *  HA_GS_SITE_MERGE  -- when two sites are about to merge
 * Domain master node (NS) notification
 *  HA_GS_DOMAIN_MASTER_NODE  - NS node change
 * Generic split/merge handling - applicable for site and cluster (without site)
 *  HA_GS_SUBCLUSTER_SPLIT  -- split across two sites or in cluster
 *  HA_GS_SUBCLUSTER_MERGE  -- merge across two sites or in cluster
 *----------------------------------------------------------------------------
 */

typedef enum {
    HA_GS_DOMAIN_DISCOVER        = 1,
    HA_GS_DOMAIN_MERGE           = 2,
    HA_GS_DOMAIN_VERSION         = 3,       /* Active/install version change */
    HA_GS_DOMAIN_NODE_CONFIG     = 4,       /* configuration is changed */
    HA_GS_MIGRATE_TO_CAA         = 5,       /* migrate to CAA           */
    HA_GS_SITE_SPLIT             = 6,       /* site down or split */
    HA_GS_SITE_MERGE             = 7,       /* site merge */
    HA_GS_DOMAIN_MASTER_NODE     = 8,       /* domain master node change */
    HA_GS_SUBCLUSTER_SPLIT       = 9,       /* generic split */
    HA_GS_SUBCLUSTER_MERGE       = 10,      /* generic merge */
    HA_GS_OPQUORUM_INFO          = 11,      /* Provides quorum values */
    HA_GS_DOMAINCB_RESP_ERR_INFO = 12,      /* Domain callback response error information */
    HA_GS_DOMAIN_STATUS_CHANGE   = 13,      /* Domain info (quorum) may become stale or resumed from this msg */
	HA_GS_INTERNAL_MSG_INFO  = (0x10000000 + 1)      /* internal msg - RESERVED for IBM INTERNAL USE */
} ha_gs_domain_event_type_t;


typedef enum {
    HA_GS_DOMAIN_CAA_MIGRATION_COORD = 1,  /* client is being informed that  */
                                           /* migration to CAA is being      */
                                           /* prepared and a vote is requested.*/
    HA_GS_DOMAIN_CAA_MIGRATION_APPRVD = 2, /* client is being informed that  */
                                           /* the preparation has been       */
                                           /* successful and all clients on  */
                                           /* the node approved the migration*/
                                           /* request                        */
    HA_GS_DOMAIN_CAA_MIGRATION_REJCTD = 3, /* client is being informed that  */
                                           /* the preparation failed         */ 
    HA_GS_DOMAIN_CAA_MIGRATION_COMPLT = 4  /* client is being informed that  */
                                           /* the migration request has been */
                                           /* completed, which succeeds the  */
                                           /* call to                        */
                                           /* ha_gs_migrate_to_caa_commit() .*/
} ha_gs_migrate_to_caa_subtype_info_t;


typedef enum {
    HA_GS_VOTE_FOR_MIGRATION 		= 0,	/* Ask for a vote for migration to CAA */ 
    HA_GS_MIGRATE_TO_CAA_PREP_DONE	= 1,	/* migration to CAA  approved */
    HA_GS_MIGRATE_TO_CAA_COMMIT_DONE	= 2,	/* migration to CAA completed */
    HA_GS_HB_MIGRATE_TO_CAA_PREP_FAILED	= 3,	/* hb_migrate_to_caa_prep() returned error */
    HA_GS_CT2PRMMIGRATETOCAAPREP_FAILED	= 4,	/* ct2PrmMigrateToCAAPrep() returned error */
    HA_GS_MIGRATE_TO_CAA_ALREADY_DONE	= 5,	/* migration to CAA already done */
    HA_GS_VOTE_FOR_MIGRATION_NOT_SUPPORTED = 6, /* vote for migration to CAA is not supported */
    HA_GS_INVALID_MIGRATION_TO_CAA_CALL = 7     /* invalid migration to CAA call */
} ha_gs_migrate_notification_reason_t;

#define HA_GS_MIGRATION_REASON_MSG_SIZE    100

typedef struct {
       ha_gs_migrate_to_caa_subtype_info_t        sub_type;
       ha_gs_migrate_notification_reason_t        reason;
       int32_t                                    reason_detail_code;
       char                                       reason_msg[HA_GS_MIGRATION_REASON_MSG_SIZE];
} ha_gs_migrate_to_caa_info_t ;

/* Domain specification (in a same site) */
typedef struct {
    uint32_t            node_number;       /* NS node number/id */
    uint32_t            instance_id;       /* NS instance number */
    uint32_t            size;
} ha_gs_domain_spec_t;


/* HA_GS_DOMAIN_DISCOVER */
typedef struct {
    ha_gs_domain_spec_t   gs_domain;            /* my domain */
    ha_gs_ip_addr         ip_addr;		/* IPv4 IP address */
    unsigned int          instance_id;		/* TS instance number */
} ha_gs_domain_discover_info_t;

/* HA_GS_DOMAIN_MERGE */
typedef struct {
    ha_gs_domain_spec_t     gs_domain;           /* my domain */
    ha_gs_domain_spec_t     other_domain;        /* other domain */
    ha_gs_node_membership_t *gs_domain_members;    /* my domain's nodes */
    ha_gs_node_membership_t *other_domain_members; /* other domain's nodes */
} ha_gs_domain_merge_info_t;

/* HA_GS_SITE_SPLIT/MERGE */

/* Site specification for site split/merge handling  */
typedef struct {
    uint32_t     site_number;      /* short site number */
    ha_gs_uuid_t site_uuid;        /* site uuid */
    uint32_t     site_policy;	   /* site policy */
    uint32_t     site_priority;    /* site priority */
    int32_t      site_size;        /* 0: unused, 'up-nodes' for merge notification */
} ha_gs_site_spec_t;

/* site dissolution action (same as critrsrc_prot method) */
typedef enum {
    HA_GS_SITE_DISSOLVE_AND_DEFAULT 	= 0,	/* determined internally */
    HA_GS_SITE_DISSOLVE_AND_REBOOT  	= 1,
    HA_GS_SITE_DISSOLVE_AND_HALT    	= 2,
    HA_GS_SITE_DISSOLVE_AND_SYNC_REBOOT = 3,
    HA_GS_SITE_DISSOLVE_AND_SYNC_HALT   = 4,
    HA_GS_SITE_DISSOLVE_AND_NONE 	= 5,
    HA_GS_SITE_DISSOLVE_AND_EXIT	= 6
} ha_gs_site_dissolve_action_t;

/* HA_GS_SITE_SPLIT */
typedef struct {
    ha_gs_site_spec_t       gs_local_site;	/* my local site */
    ha_gs_site_spec_t	    gs_other_site;      /* other site */
} ha_gs_site_split_info_t;

/* HA_GS_SITE_MERGE */
typedef struct {
    ha_gs_site_spec_t       gs_local_site;        /* my local site */
    ha_gs_site_spec_t       gs_other_site;        /* other site */
} ha_gs_site_merge_info_t;


/* HA_GS_SPLIT/MERGE */

/* split/merge subtype */
typedef enum
{
    HA_GS_SUBCLUSTER_TYPE_LOCAL = 0,
    HA_GS_SUBCLUSTER_TYPE_REMOTE = 1
} ha_gs_subcluster_type_t;

typedef enum {
    HA_GS_SUBCLUSTER_DISSOLVE_AND_DEFAULT     = 0,    /* determined internally */
    HA_GS_SUBCLUSTER_DISSOLVE_AND_REBOOT      = 1,
    HA_GS_SUBCLUSTER_DISSOLVE_AND_HALT        = 2,
    HA_GS_SUBCLUSTER_DISSOLVE_AND_SYNC_REBOOT = 3,
    HA_GS_SUBCLUSTER_DISSOLVE_AND_SYNC_HALT   = 4,
    HA_GS_SUBCLUSTER_DISSOLVE_AND_NONE        = 5,
    HA_GS_SUBCLUSTER_DISSOLVE_AND_EXIT        = 6
} ha_gs_subcluster_dissolve_action_t;

typedef struct {
    ha_gs_domain_spec_t           gs_local_domain;
    ha_gs_site_spec_t             gs_local_site;
    ha_gs_site_spec_t             gs_other_site;
    ha_gs_node_membership_t       gs_local_subcluster;           /* local subcluster */
    ha_gs_node_membership_t       gs_other_subcluster;           /* other subcluster */
    ha_gs_subcluster_type_t       gs_subcluster_type;            /* subcluster type - local or remote */
    uint64_t                      gs_event_seqnum;
} ha_gs_subcluster_split_merge_info_t;

typedef struct {
    ha_gs_subcluster_type_t       gs_subcluster_type;
    ha_gs_subcluster_dissolve_action_t action;
    union {
         ha_gs_domain_spec_t  local_domain;
         ha_gs_site_spec_t    site_spec;
    }info;
} ha_gs_subcluster_dissolution_info_t;

/* HA_GS_DOMAIN_VERSION */
typedef struct {
    struct {
          uint16_t      version;
          uint16_t      release;
          uint16_t      modlevel;
          uint16_t      fixlevel;
    } vrmf;
    uint32_t            quick_version;    /* combined VRMF */
} ha_gs_rsct_version_t;

/* HA_GS_DOMAIN_NODE_CONFIG (Node configuration change) */
typedef struct {
    ha_gs_node_membership_t *current;
    ha_gs_node_membership_t *added;
    ha_gs_node_membership_t *removed;
} ha_gs_domain_membership_info_t;


/***************************************************************************************************************/
/* Note notification_sequence is an increasing number. */
/* This sequence is used to indicate the order of the events (e.g. quorum_info and domain_status) */
/* Therefore, if an quorum_info's sequence is smaller than a domain_status's sequence, */
/* it implies that the quorum_info event happened before the event that caused the domain_status change */
/***************************************************************************************************************/

/***************************************************************************************************************/
/* Quorum State notification */
/***************************************************************************************************************/

typedef enum {
        HA_GS_QUORUM_STATE_HAS      = 0,
        HA_GS_QUORUM_STATE_PENDING  = 1,
        HA_GS_QUORUM_STATE_NONE     = 2
} ha_gs_quorum_state_t;

/* Quorum Notification specification */
typedef struct {
     uint64_t               notification_sequence;
     ha_gs_quorum_state_t   old_quorum_val;                         
     ha_gs_quorum_state_t   new_quorum_val;
     uint64_t               gs_event_seqnum;   /* This may always be 0 as it may be associated with an event */
} ha_gs_opquorum_info_t;                                    

/* Quorum Notification Response */
typedef struct {
        uint64_t       notification_sequence;
        void           *reserved_field;
} ha_gs_quorum_response_t;


/* Quorum response error information */
typedef struct {
   ha_gs_quorum_response_t  quorum_resp;
   ha_gs_rc_t  error_code;
} ha_gs_quorum_resp_err_t;

/* Domain callback response error information */
typedef struct {
   ha_gs_domain_event_type_t    domain_event_type;  /* domain event type */
   union {
       ha_gs_quorum_resp_err_t  quorum_resp_err;
   } err_info;
} ha_gs_domaincb_resp_err_t;


/***************************************************************************************************************/
/* Domain status change info */
/***************************************************************************************************************/

typedef enum {
        HA_GS_DOMAIN_STATUS_SUSPENDED = 0,           /* domain info msg is suspended  */
        HA_GS_DOMAIN_STATUS_ACTIVE_OR_RESUMED  = 1   /* active by default, or resumed */
}ha_gs_domain_status_t;

typedef struct {
     uint64_t              notification_sequence;
     ha_gs_domain_status_t domain_status;
} ha_gs_domain_status_info_t;


/***************************************************************************************************************/
/* RESERVED for IBM INTERNAL USE: priv channel msg notification */
/***************************************************************************************************************/

typedef struct
{
   void *msg;  /* interpreted internally */
} ha_gs_internal_msg_info_t;



/* Domain event notification */
typedef struct {
    ha_gs_notification_type_t           notification_type;   /* HA_GS_DOMAIN_NOTIFICATION */
    ha_gs_domain_event_type_t           domain_event_type;   /* domain event type */
    union {
        ha_gs_domain_discover_info_t               discover;                     /* HA_GS_DOMAIN_DISCOVER */
        ha_gs_domain_merge_info_t                  merge;                        /* HA_GS_DOMAIN_MERGE */
        ha_gs_rsct_version_t                       vers;                         /* HA_GS_DOMAIN_VERSION */
        ha_gs_domain_membership_info_t             nodes;                        /* HA_GS_DOMAIN_NODE_CONFIG */
        ha_gs_migrate_to_caa_info_t                migrate_event_info;           /* HA_GS_MIGRATE_TO_CAA - migration to CAA info */
        ha_gs_site_merge_info_t                    site_merge;                   /* HA_GS_SITE_MERGE */
        ha_gs_site_split_info_t                    site_split;                   /* HA_GS_SITE_SPLIT */
        ha_gs_domain_spec_t                        domain_master_info;           /* HA_GS_DOMAIN_MASTER_NODE */
        ha_gs_opquorum_info_t                      quorum_val;                   /* HA_GS_OPQUORUM_INFO */
        ha_gs_subcluster_split_merge_info_t        subcluster_split;             /* HA_GS_SPLIT */
        ha_gs_subcluster_split_merge_info_t        subcluster_merge;             /* HA_GS_MERGE */
        ha_gs_domaincb_resp_err_t                  domaincb_resp_err;            /* HA_GS_DOMAINCB_RESP_ERR_INFO */
        ha_gs_domain_status_info_t                 domain_status_info;      /* HA_GS_DOMAIN_STATUS_CHANGE */
        ha_gs_internal_msg_info_t                  internal_msg;         /* HA_GS_INTERNAL_MSG_INFO  - RESERVED for IBM INTERNAL USE */
    } info;
} ha_gs_domain_control_notification_t;  /* keep the same name for the compatibility */

/***************************************************/
/*   Handling Domain Callback Acknowledgement      */
/***************************************************/

/* Domain Callback Acknowledgement */
typedef struct {
    ha_gs_notification_type_t           notification_type;   /* HA_GS_DOMAIN_NOTIFICATION */
    ha_gs_domain_event_type_t           domain_event_type;   /* domain event type */
    union {
               ha_gs_quorum_response_t  quorum_response;
    } info;
} ha_gs_domain_control_response_t;

/* Domain Callback Acknowledgement Timeout */
typedef struct {
     ha_gs_time_limit_t  gs_domaincb_ack_time_limit;
} ha_gs_domaincb_ack_timeout_t;

#ifdef _USE_DEDICATED_THREAD_MODEL  /* begin _USE_DEDICATED_THREAD_MODEL */

/*************************************************************/
/* Handling of dedicated thread dispatching model - RESERVED */
/*************************************************************/

/* token bit masks */
#define HA_GS_ALL_TOKENS_MASK                        0x7FFFFFFF	    
#define HA_GS_PREDEFINED_TOKEN_MASK		     0x00FF0000           
#define HA_GS_ALL_PREDEFINED_TOKENS		     0x00FFFFFF 	    
#define HA_GS_RESPONSIVENESS_MSG_TOKEN_CATEGORY_BIT  0x00010000 	   
#define HA_GS_QUERY_MSG_TOKEN_CATEGORY_BIT           0x00020000 	   
#define HA_GS_DOMAINCONTROL_MSG_TOKEN_CATEGORY_BIT   0x00040000 

/*** token definitions ***/
#define HA_GS_CATCH_ALL_TOKEN			0xFF01000

/** non-group related predefined tokens **/

/* responsiveness callback token */
#define HA_GS_RESPONSIVENESS_MSG_TOKEN                    (HA_GS_RESPONSIVENESS_MSG_TOKEN_CATEGORY_BIT | 0x00000001) 

/* query message token */
#define HA_GS_QUERY_MSG_TOKEN                             (HA_GS_QUERY_MSG_TOKEN_CATEGORY_BIT | 0x00000002) 

/* domain control tokens */
#define HA_GS_DOMAINCONTROL_DOMAIN_DISCOVER_MSG_TOKEN     (HA_GS_DOMAINCONTROL_MSG_TOKEN_CATEGORY_BIT | 0x00000003) 
#define HA_GS_DOMAINCONTROL_DOMAIN_MERGE_MSG_TOKEN        (HA_GS_DOMAINCONTROL_MSG_TOKEN_CATEGORY_BIT | 0x00000004) 
#define HA_GS_DOMAINCONTROL_DOMAIN_VERSION_MSG_TOKEN      (HA_GS_DOMAINCONTROL_MSG_TOKEN_CATEGORY_BIT | 0x00000005) 
#define HA_GS_DOMAINCONTROL_DOMAIN_NODE_CONFIG_MSG_TOKEN  (HA_GS_DOMAINCONTROL_MSG_TOKEN_CATEGORY_BIT | 0x00000006)
#define HA_GS_DOMAINCONTROL_MIGRATE_TO_CAA_MSG_TOKEN      (HA_GS_DOMAINCONTROL_MSG_TOKEN_CATEGORY_BIT | 0x00000007)
#define HA_GS_DOMAINCONTROL_SITE_SPLIT_MSG_TOKEN          (HA_GS_DOMAINCONTROL_MSG_TOKEN_CATEGORY_BIT | 0x00000008)
#define HA_GS_DOMAINCONTROL_SITE_MERGE_MSG_TOKEN          (HA_GS_DOMAINCONTROL_MSG_TOKEN_CATEGORY_BIT | 0x00000009)
#define HA_GS_DOMAINCONTROL_DOMAIN_MASTER_NODE_MSG_TOKEN  (HA_GS_DOMAINCONTROL_MSG_TOKEN_CATEGORY_BIT | 0x0000000A)
#define HA_GS_DOMAINCONTROL_SUBCLUSTER_SPLIT_MSG_TOKEN    (HA_GS_DOMAINCONTROL_MSG_TOKEN_CATEGORY_BIT | 0x0000000B) 
#define HA_GS_DOMAINCONTROL_SUBCLUSTER_MERGE_MSG_TOKEN    (HA_GS_DOMAINCONTROL_MSG_TOKEN_CATEGORY_BIT | 0x0000000C)
#define HA_GS_DOMAINCONTROL_OPQUORUM_INFO_MSG_TOKEN       (HA_GS_DOMAINCONTROL_MSG_TOKEN_CATEGORY_BIT | 0x0000000D)

/* handle to a set of tokens for dispatching requests */
typedef uint64_t ha_gs_tokenset_id_t;

/* token set purpose */
typedef enum {
        HA_GS_DISPATCH_TOKENSET = 0
}ha_gs_tokenset_type_t;

/* Tokenset membership */
typedef struct {
    unsigned int                      num_tokens;
    ha_gs_token_t                     *token_list;
} ha_gs_tokenset_membership_t;

/* create and delete a tokensets */
ha_gs_rc_t  ha_gs_create_tokenset( ha_gs_tokenset_type_t	type,
                                   ha_gs_tokenset_id_t		*p_tokenset_id );

ha_gs_rc_t ha_gs_create_catchall_tokenset( ha_gs_tokenset_type_t	type,
                                           ha_gs_tokenset_id_t		*p_tokenset_id );

ha_gs_rc_t  ha_gs_delete_tokenset( ha_gs_tokenset_id_t	tokenset );


/* add and remove tokens from a set */
ha_gs_rc_t  ha_gs_add_token( ha_gs_tokenset_id_t	tokenset,
                             ha_gs_token_t 		token);

ha_gs_rc_t  ha_gs_remove_token( ha_gs_tokenset_id_t	tokenset,
                                ha_gs_token_t		token );

/* query a token set */
ha_gs_rc_t  ha_gs_get_tokenset_members( ha_gs_tokenset_id_t	tokenset,
                                        ha_gs_tokenset_membership_t  *member_tokens_info);

/* acquire a tokenset's descriptor */
ha_gs_rc_t  ha_gs_get_dispatch_tokenset_descriptor( ha_gs_tokenset_id_t	tokenset,
                                                    ha_gs_descriptor_t	*p_fd);

/* query which tokenset(s) a token is a member */
ha_gs_rc_t  ha_gs_get_token_tokensets( ha_gs_token_t	    token,
                                       ha_gs_tokenset_id_t  **tokensets,
                                       int                  *p_count );

/* dispatch request(s) for an assigned set of tokens */
ha_gs_rc_t  ha_gs_dispatch_tokenset( ha_gs_dispatch_flag_t	mode,
                       		     ha_gs_tokenset_id_t	tokenset );

#endif /* end _USE_DEDICATED_THREAD_MODEL */

/* domain callback */
typedef ha_gs_domain_control_notification_t ha_gs_domain_event_notification_t;
typedef void (ha_gs_domain_control_cb_t)(const ha_gs_domain_control_notification_t *notification);

/* IBM internal use */

/* Get the internal domain master node (e.g. NS).
 * If it is equal to node_number from ha_gs_get_node_number(), 
 * it is the Group Services master node
 */

ha_gs_rc_t ha_gs_get_domain_master_node_number(int *node_number);

ha_gs_rc_t ha_gs_dissolve_domain(const ha_gs_domain_spec_t *local_domain); /* domain merge handling */

/* site merge/split handling */
ha_gs_rc_t ha_gs_dissolve_site(const ha_gs_site_spec_t  *local_site, ha_gs_site_dissolve_action_t action); 

/*--------------------------------------------------------------
 * InstalledVersion: it will always be the local RSCT version.
 * ActiveVersion: This will provide the current Peer Domain Active Version.
 *                Therefore, this will be NULL on non-peer domain environment.
 * Return NULL if not available.
 *--------------------------------------------------------------
 */
ha_gs_rc_t ha_gs_get_rsct_active_version(ha_gs_rsct_version_t *avn);
ha_gs_rc_t ha_gs_get_rsct_installed_version(ha_gs_rsct_version_t *ivn);

/*--------------------------------------------------------------
 * migration APIs for pre-CAA to CAA mode
 *
 *--------------------------------------------------------------
 */
ha_gs_rc_t ha_gs_migrate_to_caa_prep();
ha_gs_rc_t ha_gs_migrate_to_caa_commit();
ha_gs_rc_t ha_gs_migrate_to_caa_abort();
ha_gs_rc_t ha_gs_migrate_vote( ha_gs_migration_vote_t _vote );

/* For sending domain callback acknowledgement */
ha_gs_rc_t ha_gs_respond_domain_control(const ha_gs_domain_control_response_t *response);

/* For changing the domain callback acknowledgement time-out value */
ha_gs_rc_t ha_gs_change_domaincb_ack_timeout(const ha_gs_time_limit_t  *gs_domain_control_ack_time_limit);

/* subcluster dissolution */
ha_gs_rc_t ha_gs_dissolve_subcluster(const ha_gs_subcluster_dissolution_info_t *subcluster_info);

#ifdef __cplusplus
}                                       /* end extern "C" */
#endif

#endif                                  /* _HA_GS_H_ */