/*                               -*- Mode: C -*- 
 * ndmp.x
 * 
 * Description     : NDMP protocol rpcgen file.
 * 
 * Copyright (c) 1996,1997 PDC, Network Appliance. All Rights Reserved.
 *
 * $Id: ndmp.x,v 1.1.1.1.2.4 1997/02/21 06:26:35 tim Exp $
 */

%#ifdef RPC_HDR
%#if !defined(lint) && !defined(SABER)
%static char ndmp_h_rcsId[] = "@(#) $Id: ndmp.x,v 1.1.1.1.2.4 1997/02/21 06:26:35 tim Exp $";
%#endif
%#endif

const NDMPVER = 1;
const NDMPPORT = 10000;

struct     ndmp_u_quad
{
	u_long     high;
	u_long     low;
};

struct ndmp_pval
{
	string     name<>;
	string     value<>;
};

struct ndmp_scsi_device
{
	string name<>;
};

struct ndmp_tape_device
{
	string name<>;
};

enum ndmp_error
{
	NDMP_NO_ERR,                  /* No error */
	NDMP_NOT_SUPPORTED_ERR,       /* Call is not supported */
	NDMP_DEVICE_BUSY_ERR,         /* The device is in use */
	NDMP_DEVICE_OPENED_ERR,       /* Another tape or scsi device 
								   * is already open */
	NDMP_NOT_AUTHORIZED_ERR,      /* connection has not been authorized */
	NDMP_PERMISSION_ERR,          /* some sort of permission problem */
	NDMP_DEV_NOT_OPEN_ERR,        /* SCSI device is not open */
	NDMP_IO_ERR,                  /* I/O error */
	NDMP_TIMEOUT_ERR,             /* command timed out */
	NDMP_ILLEGAL_ARGS_ERR,        /* illegal arguments in request */
	NDMP_NO_NDMP_TAPE_LOADED_ERR, /* Cannot open because there is */
	NDMP_WRITE_PROTECT_ERR,       /* tape cannot be open for write */
	NDMP_EOF_ERR,                 /* Command encountered EOF */
	NDMP_EOM_ERR,                 /* Command encountered EOM */
	NDMP_FILE_NOT_FOUND_ERR,      /* File not found during restore */
	NDMP_BAD_FILE_ERR,            /* The file descriptor is invalid */
	NDMP_NO_DEVICE_ERR,           /* The device is not at that target */
	NDMP_NO_BUS_ERR,              /* Invalid controller */
	NDMP_XDR_DECODE_ERR,          /* Can't decode the request argument */
	NDMP_ILLEGAL_STATE_ERR,       /* Call can't be performed at this state */
	NDMP_UNDEFINED_ERR,           /* Undefined Error */
	NDMP_XDR_ENCODE_ERR,          /* Can't encode the reply argument */
	NDMP_NO_MEM_ERR               /* no memory */

};

enum ndmp_header_message_type
{
	NDMP_REQUEST,
	NDMP_REPLY
};

enum ndmp_message
{
	NDMP_CONNECT_OPEN = 0x900,            /* CONNECT INTERFACE */
	NDMP_CONNECT_AUTH,
	NDMP_CONNECT_CLOSE,

	NDMP_CONFIG_GET_HOST_INFO=0x100,      /* CONFIG INTERFACE */
	NDMP_CONFIG_GET_BUTYPE_ATTR,

	NDMP_SCSI_OPEN=0x200,                 /* SCSI INTERFACE */
	NDMP_SCSI_CLOSE,
	NDMP_SCSI_GET_STATE,
	NDMP_SCSI_SET_TARGET,
	NDMP_SCSI_RESET_DEVICE,
	NDMP_SCSI_RESET_BUS,
	NDMP_SCSI_EXECUTE_CDB,

	NDMP_TAPE_OPEN=0x300,                 /* TAPE INTERFACE */
	NDMP_TAPE_CLOSE,
	NDMP_TAPE_GET_STATE,
	NDMP_TAPE_MTIO,
	NDMP_TAPE_WRITE,
	NDMP_TAPE_READ,
	NDMP_TAPE_SET_RECORD_SIZE,
	NDMP_TAPE_EXECUTE_CDB,

	NDMP_DATA_GET_STATE=0x400,            /* DATA INTERFACE */
	NDMP_DATA_START_BACKUP,
	NDMP_DATA_START_RECOVER,
	NDMP_DATA_ABORT,
	NDMP_DATA_GET_ENV,
	NDMP_DATA_RESVD1,
	NDMP_DATA_RESVD2,
	NDMP_DATA_STOP,
	NDMP_DATA_CONTINUE,

	NDMP_NOTIFY_PAUSED=0x500,             /* NOTIFY INTERFACE */
	NDMP_NOTIFY_HALTED,
	NDMP_NOTIFY_CONNECTED,

	NDMP_LOG_LOG=0x600,                   /* LOGGING INTERFACE */
	NDMP_LOG_DEBUG,
	NDMP_LOG_FILE,

	NDMP_FH_ADD_UNIX_PATH=0x700,          /* FILE HISTORY INTERFACE */
	NDMP_FH_ADD_UNIX_DIR,
	NDMP_FH_ADD_UNIX_NODE
};

struct     ndmp_header
{
	u_long						sequence; /* monotonically increasing number */
	u_long						time_stamp;  /* time stamp of message */
	ndmp_header_message_type	message_type;/* what type of message */
	enum ndmp_message			proceedure;  /* message number */
	u_long     					reply_sequence;  /* reply is in response to */
	ndmp_error     				error;       /* communications errors */
};


/* NDMP_CONNECT_OPEN */
struct ndmp_connect_open_request
{
	u_short		protocol_version;     /* the version of protocol supported */
};

struct ndmp_connect_open_reply
{
	ndmp_error	error;
};

/* NDMP_CONNECT_AUTH */
enum ndmp_auth_type
{
	NDMP_AUTH_NONE,     /* no password is required */
	NDMP_AUTH_TEXT      /* the clear text password */
};

struct ndmp_auth_text
{
	string		user <>;
	string		password<>;
};

struct ndmp_auth_pcnfs
{
	string		user <>;
	string		password <>;
};

union ndmp_auth_data switch (enum ndmp_auth_type auth_type)
{
	case NDMP_AUTH_NONE:
		void;
	case NDMP_AUTH_TEXT:
		struct ndmp_auth_text     auth_text;
};

struct ndmp_connect_auth_request
{
	ndmp_auth_data     auth_data;
};

struct ndmp_connect_auth_reply
{
	ndmp_error		error;
};

/* NDMP_CONNECT_CLOSE */
/* no request arguments */
/* no reply arguments */


/* NDMP_CONFIG_GET_HOST_INFO */
/* no request arguments */
struct ndmp_config_get_host_info_reply
{
	ndmp_error		error;
	string			hostname<>;        /* host name */
	string			os_type<>;         /* The operating system type (i.e.
										* SOLARIS) */
	string			os_vers<>;         /* The version number of the OS (i.e.
										* 2.5) */
	string			hostid<>;
	ndmp_auth_type	auth_type<>;
};

/* NDMP_CONFIG_GET_BUTYPE_ATTR */
const NDMP_NO_BACKUP_FILELIST =      0x0001;
const NDMP_NO_BACKUP_FHINFO =        0x0002;
const NDMP_NO_RECOVER_FILELIST =     0x0004;
const NDMP_NO_RECOVER_FHINFO =       0x0008;
const NDMP_NO_RECOVER_SSID =         0x0010;
const NDMP_NO_RECOVER_INC_ONLY =     0x0020;

struct ndmp_config_get_butype_attr_request
{
	string			name <>;     /* backup type name */
};

struct ndmp_config_get_butype_attr_reply
{
	ndmp_error		error;
	u_long			attrs;
};


/* NDMP_SCSI_OPEN */
struct ndmp_scsi_open_request
{
	ndmp_scsi_device		device;
};

struct ndmp_scsi_open_reply
{
	ndmp_error		error;
};

/* NDMP_SCSI_CLOSE */
/* no request arguments */
struct ndmp_scsi_close_reply
{
	ndmp_error		error;
};

/* NDMP_SCSI_GET_STATE */
/* no request arguments */
struct ndmp_scsi_get_state_reply
{
	ndmp_error		error;
	short			target_controller;
	short			target_id;
	short			target_lun;
};

/* NDMP_SCSI_SET_TARGET */
struct ndmp_scsi_set_target_request
{
	ndmp_scsi_device	device;
	u_short				target_controller;
	u_short				target_id;
	u_short				target_lun;
};

struct ndmp_scsi_set_target_reply
{
	ndmp_error		error;
};

/* NDMP_SCSI_RESET_DEVICE */
/* no request arguments */
struct ndmp_scsi_reset_device_reply
{
	ndmp_error		error;
};

/* NDMP_SCSI_RESET_BUS */
/* no request arguments */
struct ndmp_scsi_reset_bus_reply
{
	ndmp_error		error;
};

/* NDMP_SCSI_EXECUTE_CDB */
const NDMP_SCSI_DATA_IN  = 0x00000001;     /* Expect data from SCSI device */
const NDMP_SCSI_DATA_OUT = 0x00000002;     /* Transfer data to SCSI device */

struct ndmp_execute_cdb_request
{
	u_long			flags;
	u_long			timeout;
	u_long			alloc_len;          /* Set for expected datain */
	opaque			cdb<>;
	opaque			dataout<>;
};

struct     ndmp_execute_cdb_reply
{
	ndmp_error		error;
	u_char			status;       /* SCSI status bytes */
	u_long			dataout_len;
	opaque			datain<>;          /* SCSI datain */
	opaque			ext_sense<>;       /* Extended sense data */
};

/* NDMP_TAPE_OPEN */
enum ndmp_tape_open_mode
{
	NDMP_TAPE_READ_MODE,
	NDMP_TAPE_WRITE_MODE
};

struct ndmp_tape_open_request
{
	ndmp_tape_device	device;
	ndmp_tape_open_mode	mode;
};
struct ndmp_tape_open_reply
{
	ndmp_error		error;
};

/* NDMP_TAPE_CLOSE */
/* no request arguments */
struct ndmp_tape_close_reply
{
	ndmp_error		error;
};

/*NDMP_TAPE_GET_STATE */
/* no request arguments */
const NDMP_TAPE_NOREWIND =      0x0008;     /* non-rewind device */
const NDMP_TAPE_WR_PROT =       0x0010;     /* write-protected */
const NDMP_TAPE_ERROR =         0x0020;     /* media error */
const NDMP_TAPE_UNLOAD =        0x0040;     /* tape will be unloaded when
											 * the device is closed */

struct ndmp_tape_get_state_reply
{
	ndmp_error		error;
	u_long			flags;
	u_long			file_num;
	u_long			record_num;
	u_long			record_size;
	u_long			soft_errors;
	u_long			block_size;
	u_long			blockno;
	ndmp_u_quad		total_space;
	ndmp_u_quad		space_remain;
};

/* NDMP_TAPE_MTIO */
enum ndmp_tape_mtio_op
{
	NDMP_MTIO_FSF,
	NDMP_MTIO_BSF,
	NDMP_MTIO_FSR,
	NDMP_MTIO_BSR,
	NDMP_MTIO_REW,
	NDMP_MTIO_EOF,
	NDMP_MTIO_OFF
};

struct ndmp_tape_mtio_request
{
	ndmp_tape_mtio_op	tape_op;
	u_long     count;
};

struct ndmp_tape_mtio_reply
{
	ndmp_error			error;
	u_long				resid_count;
};

/* NDMP_TAPE_WRITE */
struct ndmp_tape_write_request
{
	opaque				data_out<>;
};

struct ndmp_tape_write_reply
{
	ndmp_error			error;
	u_long				count;
};

/* NDMP_TAPE_READ */
struct ndmp_tape_read_request
{
	u_long				count;
};

struct ndmp_tape_read_reply
{
	ndmp_error			error;
	opaque				data_in<>;
};

/* NDMP_TAPE_SET_RECORD_SIZE */
struct ndmp_tape_set_record_size_request
{
	u_long				len;
};

struct ndmp_tape_set_record_size_reply
{
	ndmp_error			error;
};

/* NDMP_TAPE_EXECUTE_CDB */
typedef ndmp_execute_cdb_request	ndmp_tape_execute_cdb_request;
typedef ndmp_execute_cdb_reply		ndmp_tape_execute_cdb_reply;


/* GET_NDMP_DATA_STATE */
/* no request arguments */
enum ndmp_data_operation
{
	NDMP_DATA_OP_NOACTION,
	NDMP_DATA_OP_BACKUP,
	NDMP_DATA_OP_RESTORE
};

enum ndmp_data_state
{
	NDMP_DATA_STATE_IDLE,
	NDMP_DATA_STATE_ACTIVE,
	NDMP_DATA_STATE_PAUSED,
	NDMP_DATA_STATE_HALTED
};

enum ndmp_data_halt_reason
{
	NDMP_HALT_NA,
	NDMP_HALT_SUCCESSFUL,
	NDMP_HALT_ABORTED,
	NDMP_HALT_MEDIA_ERROR,
	NDMP_HALT_INTERNAL_ERROR,
	NDMP_HALT_NO_SPLIT
};

enum ndmp_data_pause_reason
{
	NDMP_PAUSE_NA,
	NDMP_PAUSE_EOM,
	NDMP_PAUSE_EOF,
	NDMP_PAUSE_RSVD
};

struct ndmp_data_get_state_reply
{
	ndmp_error				error;
	ndmp_data_operation		operation;
	ndmp_data_state			state;
	ndmp_data_halt_reason	halt_reason;
	ndmp_data_pause_reason	pause_reason;
	ndmp_u_quad				reserved1;
	ndmp_u_quad				bytes_processed;
	ndmp_u_quad				est_bytes_remain;
	u_long					est_time_remain;
	ndmp_u_quad				reserved2;
	ndmp_u_quad				reserved3;
};

/* NDMP_DATA_START_BACKUP */
struct ndmp_data_start_backup_request
{
	string				bu_type<>;     /* backup method to use */
	ndmp_pval			env<>;         /* Parameters that may modify backup */
};

struct ndmp_data_start_backup_reply
{
	ndmp_error			error;
};

/* NDMP_DATA_START_RECOVER */
struct ndmp_name
{
	string				name<>;
	string				dest<>;
	u_short				ssid;
	ndmp_u_quad			fh_info;
};

struct ndmp_data_start_recover_request
{
	ndmp_pval			env<>;
	ndmp_name			nlist<>;
	string				bu_type<>;

};

struct ndmp_data_start_recover_reply
{
	ndmp_error			error;
};

/* NDMP_DATA_ABORT */
/* no request arguments */
struct ndmp_data_abort_reply
{
	ndmp_error			error;
};

/* NDMP_DATA_STOP */
/* no request arguments */
struct ndmp_data_stop_reply
{
	ndmp_error			error;
};

/* NDMP_DATA_CONTINUE */
/* no request arguments */
struct ndmp_data_continue_reply
{
	ndmp_error			error;
};

/* NDMP_DATA_GET_ENV */
/* no request arguments */
struct ndmp_data_get_env_reply
{
	ndmp_error			error;
	ndmp_pval			env<>;
};



/* NDMP_NOTIFY_PAUSED */
struct ndmp_notify_paused_request
{
	ndmp_data_pause_reason	reason;
	ndmp_u_quad				resvd1;
};
/* No reply */

/* NDMP_NOTIFY_HALTED */
struct ndmp_notify_halted_request
{
	ndmp_data_halt_reason	reason;
	string					text_reason<>;
};
/* No reply */

/* NDMP_NOTIFY_CONNECTED */
enum ndmp_connect_reason
{
	NDMP_CONNECTED,  /* Connect sucessfully */
	NDMP_SHUTDOWN,   /* Connection shutdown */
	NDMP_REFUSED     /* reach the maximum number of connections */
};
struct ndmp_notify_connected_request
{
	ndmp_connect_reason	reason;
	u_short				protocol_version;
	string				text_reason<>;
};


/* NDMP_LOG_LOG */
struct ndmp_log_log_request
{
	string				entry<>;
};
/* No reply */

/* LOG_DEBUG */
enum ndmp_debug_level
{
	NDMP_DBG_USER_INFO,
	NDMP_DBG_USER_SUMMARY,
	NDMP_DBG_USER_DETAIL,
	NDMP_DBG_DIAG_INFO,
	NDMP_DBG_DIAG_SUMMARY,
	NDMP_DBG_DIAG_DETAIL,
	NDMP_DBG_PROG_INFO,
	NDMP_DBG_PROG_SUMMARY,
	NDMP_DBG_PROG_DETAIL
};

struct ndmp_log_debug_request
{
	ndmp_debug_level	level;
	string				message<>;
};
/* No reply */

/* NDMP_LOG_FILE */
struct ndmp_log_file_request
{
	string				name<>;
	u_short				ssid;
	ndmp_error			error;
};
/* No reply */

/* NDMP_FH_ADD_UNIX_PATH */
typedef string			ndmp_unix_path<>;
enum ndmp_unix_file_type
{
	NDMP_FILE_DIR,
	NDMP_FILE_FIFO,
	NDMP_FILE_CSPEC,
	NDMP_FILE_BSPEC,
	NDMP_FILE_REG,
	NDMP_FILE_SLINK,
	NDMP_FILE_SOCK
};

struct ndmp_unix_file_stat
{
	ndmp_unix_file_type		ftype;
	u_long					mtime;
	u_long					atime;
	u_long					ctime;
	u_long					uid;
	u_long					gid;
	u_long					mode;
	ndmp_u_quad				size;
	ndmp_u_quad				fh_info;
};

struct ndmp_fh_unix_path
{
	ndmp_unix_path			name;
	ndmp_unix_file_stat		fstat;
};

struct ndmp_fh_add_unix_path_request
{
	ndmp_fh_unix_path		paths<>;
};
/* No reply */

/* NDMP_FH_ADD_UNIX_DIR */
struct ndmp_fh_unix_dir
{
	ndmp_unix_path			name;
	u_long					node;
	u_long					parent;
};

struct ndmp_fh_add_unix_dir_request
{
	ndmp_fh_unix_dir		dirs<>;
};
/* No reply */

struct ndmp_fh_unix_node
{
	ndmp_unix_file_stat		fstat;
	u_long					node;
};

struct ndmp_fh_add_unix_node_request
{
	ndmp_fh_unix_node		nodes<>;
};
/* No reply */

