3 * Traakan, Inc., Los Altos, CA
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice unmodified, this list of conditions, and the following
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 * Copyright (c) 1997 Network Appliance. All Rights Reserved.
41 * Network Appliance makes no representations concerning either
42 * the merchantability of this software or the suitability of this
43 * software for any particular purpose. It is provided "as is"
44 * without express or implied warranty of any kind.
46 * These notices must be retained in any copies of any part of this
47 * documentation and/or software.
51 %#ifndef NDMOS_OPTION_NO_NDMP2
54 const NDMP2PORT = 10000;
56 %#define ndmp2_u_quad unsigned long long
57 %extern bool_t xdr_ndmp2_u_quad();
71 struct ndmp2_scsi_device
76 struct ndmp2_tape_device
83 NDMP2_NO_ERR, /* No error */
84 NDMP2_NOT_SUPPORTED_ERR, /* Call is not supported */
85 NDMP2_DEVICE_BUSY_ERR, /* The device is in use */
86 NDMP2_DEVICE_OPENED_ERR, /* Another tape or scsi device
88 NDMP2_NOT_AUTHORIZED_ERR, /* connection has not been authorized*/
89 NDMP2_PERMISSION_ERR, /* some sort of permission problem */
90 NDMP2_DEV_NOT_OPEN_ERR, /* SCSI device is not open */
91 NDMP2_IO_ERR, /* I/O error */
92 NDMP2_TIMEOUT_ERR, /* command timed out */
93 NDMP2_ILLEGAL_ARGS_ERR, /* illegal arguments in request */
94 NDMP2_NO_TAPE_LOADED_ERR, /* Cannot open because there is
96 NDMP2_WRITE_PROTECT_ERR, /* tape cannot be open for write */
97 NDMP2_EOF_ERR, /* Command encountered EOF */
98 NDMP2_EOM_ERR, /* Command encountered EOM */
99 NDMP2_FILE_NOT_FOUND_ERR, /* File not found during restore */
100 NDMP2_BAD_FILE_ERR, /* The file descriptor is invalid */
101 NDMP2_NO_DEVICE_ERR, /* The device is not at that target */
102 NDMP2_NO_BUS_ERR, /* Invalid controller */
103 NDMP2_XDR_DECODE_ERR, /* Can't decode the request argument */
104 NDMP2_ILLEGAL_STATE_ERR, /* Call can't be done at this state */
105 NDMP2_UNDEFINED_ERR, /* Undefined Error */
106 NDMP2_XDR_ENCODE_ERR, /* Can't encode the reply argument */
107 NDMP2_NO_MEM_ERR /* no memory */
110 enum ndmp2_header_message_type
112 NDMP2_MESSAGE_REQUEST,
118 NDMP2_CONNECT_OPEN = 0x900, /* CONNECT INTERFACE */
119 NDMP2_CONNECT_CLIENT_AUTH,
121 NDMP2_CONNECT_SERVER_AUTH,
123 NDMP2_CONFIG_GET_HOST_INFO = 0x100, /* CONFIG INTERFACE */
124 NDMP2_CONFIG_GET_BUTYPE_ATTR,
125 NDMP2_CONFIG_GET_MOVER_TYPE,
126 NDMP2_CONFIG_GET_AUTH_ATTR,
128 NDMP2_SCSI_OPEN = 0x200, /* SCSI INTERFACE */
130 NDMP2_SCSI_GET_STATE,
131 NDMP2_SCSI_SET_TARGET,
132 NDMP2_SCSI_RESET_DEVICE,
133 NDMP2_SCSI_RESET_BUS,
134 NDMP2_SCSI_EXECUTE_CDB,
136 NDMP2_TAPE_OPEN = 0x300, /* TAPE INTERFACE */
138 NDMP2_TAPE_GET_STATE,
143 NDMP2_TAPE_EXECUTE_CDB,
145 NDMP2_DATA_GET_STATE = 0x400, /* DATA INTERFACE */
146 NDMP2_DATA_START_BACKUP,
147 NDMP2_DATA_START_RECOVER,
153 NDMP2_DATA_START_RECOVER_FILEHIST = 0x40b, /* same as V3.1 */
155 NDMP2_NOTIFY_RESVD1 = 0x500, /* NOTIFY INTERFACE */
156 NDMP2_NOTIFY_DATA_HALTED,
157 NDMP2_NOTIFY_CONNECTED,
158 NDMP2_NOTIFY_MOVER_HALTED,
159 NDMP2_NOTIFY_MOVER_PAUSED,
160 NDMP2_NOTIFY_DATA_READ,
162 NDMP2_LOG_LOG = 0x600, /* LOGGING INTERFACE */
166 NDMP2_FH_ADD_UNIX_PATH = 0x700, /* FILE HISTORY INTERFACE */
167 NDMP2_FH_ADD_UNIX_DIR,
168 NDMP2_FH_ADD_UNIX_NODE,
170 NDMP2_MOVER_GET_STATE = 0xa00, /* MOVER INTERFACE */
172 NDMP2_MOVER_CONTINUE,
175 NDMP2_MOVER_SET_WINDOW,
178 NDMP2_MOVER_SET_RECORD_SIZE,
180 NDMP2_RESERVED = 0xff00 /* Reserved for prototyping */
185 u_long sequence; /* monotonically increasing */
186 u_long time_stamp; /* time stamp of message */
187 ndmp2_header_message_type message_type; /* what type of message */
188 ndmp2_message message; /* message number */
189 u_long reply_sequence; /* reply is in response to */
190 ndmp2_error error; /* communications errors */
193 /**********************/
194 /* CONNECT INTERFACE */
195 /**********************/
196 /* NDMP2_CONNECT_OPEN */
197 struct ndmp2_connect_open_request
199 u_short protocol_version; /* the version of protocol supported */
202 struct ndmp2_connect_open_reply
207 /* NDMP2_CONNECT_CLIENT_AUTH */
210 NDMP2_AUTH_NONE, /* no password is required */
211 NDMP2_AUTH_TEXT, /* the clear text password */
212 NDMP2_AUTH_MD5 /* md5 */
215 struct ndmp2_auth_text
218 string auth_password<>;
221 struct ndmp2_auth_md5
224 opaque auth_digest[16];
227 union ndmp2_auth_data switch (enum ndmp2_auth_type auth_type)
229 case NDMP2_AUTH_NONE:
231 case NDMP2_AUTH_TEXT:
232 ndmp2_auth_text auth_text;
234 ndmp2_auth_md5 auth_md5;
237 struct ndmp2_connect_client_auth_request
239 ndmp2_auth_data auth_data;
242 struct ndmp2_connect_client_auth_reply
247 /* NDMP2_CONNECT_CLOSE */
248 /* no request arguments */
249 /* no reply arguments */
251 /* NDMP2_CONNECT_SERVER_AUTH */
252 union ndmp2_auth_attr switch (enum ndmp2_auth_type auth_type)
254 case NDMP2_AUTH_NONE:
256 case NDMP2_AUTH_TEXT:
259 opaque challenge[64];
262 struct ndmp2_connect_server_auth_request
264 ndmp2_auth_attr client_attr;
267 struct ndmp2_connect_server_auth_reply
270 ndmp2_auth_data auth_result;
273 /********************/
274 /* CONFIG INTERFACE */
275 /********************/
276 /* NDMP2_CONFIG_GET_HOST_INFO */
277 /* no request arguments */
278 struct ndmp2_config_get_host_info_reply
281 string hostname<>; /* host name */
282 string os_type<>; /* The O/S type (e.g. SOLARIS) */
283 string os_vers<>; /* The O/S version (e.g. 2.5) */
285 ndmp2_auth_type auth_type<>;
288 /* NDMP2_CONFIG_GET_BUTYPE_ATTR */
289 const NDMP2_NO_BACKUP_FILELIST = 0x0001;
290 const NDMP2_NO_BACKUP_FHINFO = 0x0002;
291 const NDMP2_NO_RECOVER_FILELIST = 0x0004;
292 const NDMP2_NO_RECOVER_FHINFO = 0x0008;
293 const NDMP2_NO_RECOVER_RESVD = 0x0010;
294 const NDMP2_NO_RECOVER_INC_ONLY = 0x0020;
296 struct ndmp2_config_get_butype_attr_request
298 string name<>; /* backup type name */
301 struct ndmp2_config_get_butype_attr_reply
307 /* NDMP2_CONFIG_GET_MOVER_TYPE */
308 /* no request arguments */
309 enum ndmp2_mover_addr_type
315 struct ndmp2_config_get_mover_type_reply
318 ndmp2_mover_addr_type methods<>;
321 /* NDMP2_CONFIG_GET_AUTH_ATTR */
322 struct ndmp2_config_get_auth_attr_request
324 ndmp2_auth_type auth_type;
327 struct ndmp2_config_get_auth_attr_reply
330 ndmp2_auth_attr server_attr;
336 /* NDMP2_SCSI_OPEN */
337 struct ndmp2_scsi_open_request
339 ndmp2_scsi_device device;
342 struct ndmp2_scsi_open_reply
347 /* NDMP2_SCSI_CLOSE */
348 /* no request arguments */
349 struct ndmp2_scsi_close_reply
354 /* NDMP2_SCSI_GET_STATE */
355 /* no request arguments */
356 struct ndmp2_scsi_get_state_reply
359 short target_controller;
364 /* NDMP2_SCSI_SET_TARGET */
365 struct ndmp2_scsi_set_target_request
367 ndmp2_scsi_device device;
368 u_short target_controller;
373 struct ndmp2_scsi_set_target_reply
378 /* NDMP2_SCSI_RESET_DEVICE */
379 /* no request arguments */
380 struct ndmp2_scsi_reset_device_reply
385 /* NDMP2_SCSI_RESET_BUS */
386 /* no request arguments */
387 struct ndmp2_scsi_reset_bus_reply
392 /* NDMP2_SCSI_EXECUTE_CDB */
393 const NDMP2_SCSI_DATA_IN = 0x00000001; /* Expect data from SCSI device */
394 const NDMP2_SCSI_DATA_OUT = 0x00000002; /* Transfer data to SCSI device */
396 struct ndmp2_execute_cdb_request
400 u_long datain_len; /* Set for expected datain */
405 struct ndmp2_execute_cdb_reply
408 u_char status; /* SCSI status bytes */
410 opaque datain<>; /* SCSI datain */
411 opaque ext_sense<>; /* Extended sense data */
413 typedef ndmp2_execute_cdb_request ndmp2_scsi_execute_cdb_request;
414 typedef ndmp2_execute_cdb_reply ndmp2_scsi_execute_cdb_reply;
420 /* NDMP2_TAPE_OPEN */
421 enum ndmp2_tape_open_mode
423 NDMP2_TAPE_READ_MODE,
424 NDMP2_TAPE_WRITE_MODE
427 struct ndmp2_tape_open_request
429 ndmp2_tape_device device;
430 ndmp2_tape_open_mode mode;
433 struct ndmp2_tape_open_reply
438 /* NDMP2_TAPE_CLOSE */
439 /* no request arguments */
440 struct ndmp2_tape_close_reply
445 /* NDMP2_TAPE_GET_STATE */
446 /* no request arguments */
447 const NDMP2_TAPE_NOREWIND = 0x0008; /* non-rewind device */
448 const NDMP2_TAPE_WR_PROT = 0x0010; /* write-protected */
449 const NDMP2_TAPE_ERROR = 0x0020; /* media error */
450 const NDMP2_TAPE_UNLOAD = 0x0040; /* tape will be unloaded when
451 * the device is closed */
452 struct ndmp2_tape_get_state_reply
460 ndmp2_u_quad total_space;
461 ndmp2_u_quad space_remain;
464 /* NDMP2_TAPE_MTIO */
465 enum ndmp2_tape_mtio_op
476 struct ndmp2_tape_mtio_request
478 ndmp2_tape_mtio_op tape_op;
482 struct ndmp2_tape_mtio_reply
488 /* NDMP2_TAPE_WRITE */
489 struct ndmp2_tape_write_request
494 struct ndmp2_tape_write_reply
500 /* NDMP2_TAPE_READ */
501 struct ndmp2_tape_read_request
506 struct ndmp2_tape_read_reply
512 /* NDMP2_TAPE_EXECUTE_CDB */
513 typedef ndmp2_execute_cdb_request ndmp2_tape_execute_cdb_request;
514 typedef ndmp2_execute_cdb_reply ndmp2_tape_execute_cdb_reply;
516 /********************************/
517 /* MOVER INTERFACE */
518 /********************************/
519 /* NDMP2_MOVER_GET_STATE */
520 enum ndmp2_mover_state
522 NDMP2_MOVER_STATE_IDLE,
523 NDMP2_MOVER_STATE_LISTEN,
524 NDMP2_MOVER_STATE_ACTIVE,
525 NDMP2_MOVER_STATE_PAUSED,
526 NDMP2_MOVER_STATE_HALTED
529 enum ndmp2_mover_pause_reason
531 NDMP2_MOVER_PAUSE_NA,
532 NDMP2_MOVER_PAUSE_EOM,
533 NDMP2_MOVER_PAUSE_EOF,
534 NDMP2_MOVER_PAUSE_SEEK,
535 NDMP2_MOVER_PAUSE_MEDIA_ERROR
538 enum ndmp2_mover_halt_reason
541 NDMP2_MOVER_HALT_CONNECT_CLOSED,
542 NDMP2_MOVER_HALT_ABORTED,
543 NDMP2_MOVER_HALT_INTERNAL_ERROR,
544 NDMP2_MOVER_HALT_CONNECT_ERROR
547 /* no request arguments */
548 struct ndmp2_mover_get_state_reply
551 ndmp2_mover_state state;
552 ndmp2_mover_pause_reason pause_reason;
553 ndmp2_mover_halt_reason halt_reason;
556 ndmp2_u_quad data_written;
557 ndmp2_u_quad seek_position;
558 ndmp2_u_quad bytes_left_to_read;
559 ndmp2_u_quad window_offset;
560 ndmp2_u_quad window_length;
563 /* NDMP2_MOVER_LISTEN */
564 enum ndmp2_mover_mode
566 NDMP2_MOVER_MODE_READ, /* read from data conn; write to tape */
567 NDMP2_MOVER_MODE_WRITE, /* write to data conn; read from tape */
568 NDMP2_MOVER_MODE_DATA /* write to data conn; read from data conn */
571 struct ndmp2_mover_tcp_addr
577 union ndmp2_mover_addr switch (ndmp2_mover_addr_type addr_type)
579 case NDMP2_ADDR_LOCAL:
582 ndmp2_mover_tcp_addr addr;
585 struct ndmp2_mover_listen_request
587 ndmp2_mover_mode mode;
588 ndmp2_mover_addr_type addr_type;
591 struct ndmp2_mover_listen_reply
594 ndmp2_mover_addr mover;
597 /* NDMP2_MOVER_SET_RECORD_SIZE */
598 struct ndmp2_mover_set_record_size_request
603 struct ndmp2_mover_set_record_size_reply
608 /* NDMP2_MOVER_SET_WINDOW */
609 struct ndmp2_mover_set_window_request
615 struct ndmp2_mover_set_window_reply
620 /* NDMP2_MOVER_CONTINUE */
621 /* no request arguments */
622 struct ndmp2_mover_continue_reply
627 /* NDMP2_MOVER_ABORT */
628 /* no request arguments */
629 struct ndmp2_mover_abort_reply
634 /* NDMP2_MOVER_STOP */
635 /* no request arguments */
636 struct ndmp2_mover_stop_reply
641 /* NDMP2_MOVER_READ */
642 struct ndmp2_mover_read_request
648 struct ndmp2_mover_read_reply
653 /* NDMP2_MOVER_CLOSE */
654 /* no request arguments */
655 struct ndmp2_mover_close_reply
660 /****************************/
662 /****************************/
663 /* NDMP2_DATA_GET_STATE */
664 /* no request arguments */
665 enum ndmp2_data_operation
667 NDMP2_DATA_OP_NOACTION,
668 NDMP2_DATA_OP_BACKUP,
669 NDMP2_DATA_OP_RESTORE,
670 NDMP2_DATA_OP_RESTORE_FILEHIST
673 enum ndmp2_data_state
675 NDMP2_DATA_STATE_IDLE,
676 NDMP2_DATA_STATE_ACTIVE,
677 NDMP2_DATA_STATE_HALTED
680 enum ndmp2_data_halt_reason
683 NDMP2_DATA_HALT_SUCCESSFUL,
684 NDMP2_DATA_HALT_ABORTED,
685 NDMP2_DATA_HALT_INTERNAL_ERROR,
686 NDMP2_DATA_HALT_CONNECT_ERROR
689 struct ndmp2_data_get_state_reply
692 ndmp2_data_operation operation;
693 ndmp2_data_state state;
694 ndmp2_data_halt_reason halt_reason;
695 ndmp2_u_quad bytes_processed;
696 ndmp2_u_quad est_bytes_remain;
697 u_long est_time_remain;
698 ndmp2_mover_addr mover;
699 ndmp2_u_quad read_offset;
700 ndmp2_u_quad read_length;
703 /* NDMP2_DATA_START_BACKUP */
704 struct ndmp2_data_start_backup_request
706 ndmp2_mover_addr mover; /* mover to receive data */
707 string bu_type<>; /* backup method to use */
708 ndmp2_pval env<>; /* Parameters that may modify backup */
711 struct ndmp2_data_start_backup_reply
716 /* NDMP2_DATA_START_RECOVER */
722 ndmp2_u_quad fh_info;
725 struct ndmp2_data_start_recover_request
727 ndmp2_mover_addr mover;
733 struct ndmp2_data_start_recover_reply
738 /* NDMP2_DATA_START_RECOVER_FILEHIST */
739 typedef ndmp2_data_start_recover_request ndmp2_data_start_recover_filehist_request;
740 typedef ndmp2_data_start_recover_reply ndmp2_data_start_recover_filehist_reply;
742 /* NDMP2_DATA_ABORT */
743 /* no request arguments */
744 struct ndmp2_data_abort_reply
749 /* NDMP2_DATA_STOP */
750 /* no request arguments */
751 struct ndmp2_data_stop_reply
756 /* NDMP2_DATA_GET_ENV */
757 /* no request arguments */
758 struct ndmp2_data_get_env_reply
764 /****************************/
765 /* NOTIFY INTERFACE */
766 /****************************/
767 /* NDMP2_NOTIFY_DATA_HALTED */
768 struct ndmp2_notify_data_halted_request
770 ndmp2_data_halt_reason reason;
771 string text_reason<>;
776 /* NDMP2_NOTIFY_CONNECTED */
777 enum ndmp2_connect_reason
779 NDMP2_CONNECTED, /* Connect sucessfully */
780 NDMP2_SHUTDOWN, /* Connection shutdown */
781 NDMP2_REFUSED /* reach the maximum number of connections */
784 struct ndmp2_notify_connected_request
786 ndmp2_connect_reason reason;
787 u_short protocol_version;
788 string text_reason<>;
791 /* NDMP2_NOTIFY_MOVER_PAUSED */
792 struct ndmp2_notify_mover_paused_request
794 ndmp2_mover_pause_reason reason;
795 ndmp2_u_quad seek_position;
799 /* NDMP2_NOTIFY_MOVER_HALTED */
800 struct ndmp2_notify_mover_halted_request
802 ndmp2_mover_halt_reason reason;
803 string text_reason<>;
807 /* NDMP2_NOTIFY_DATA_READ */
808 struct ndmp2_notify_data_read_request
815 /********************************/
817 /********************************/
819 struct ndmp2_log_log_request
825 /* NDMP2_LOG_DEBUG */
826 enum ndmp2_debug_level
829 NDMP2_DBG_USER_SUMMARY,
830 NDMP2_DBG_USER_DETAIL,
832 NDMP2_DBG_DIAG_SUMMARY,
833 NDMP2_DBG_DIAG_DETAIL,
835 NDMP2_DBG_PROG_SUMMARY,
836 NDMP2_DBG_PROG_DETAIL
839 struct ndmp2_log_debug_request
841 ndmp2_debug_level level;
847 struct ndmp2_log_file_request
855 /********************************/
856 /* File History INTERFACE */
857 /********************************/
858 /* NDMP2_FH_ADD_UNIX_PATH */
859 typedef string ndmp2_unix_path<>;
860 enum ndmp2_unix_file_type
871 struct ndmp2_unix_file_stat
873 ndmp2_unix_file_type ftype;
881 ndmp2_u_quad fh_info;
884 struct ndmp2_fh_unix_path
886 ndmp2_unix_path name;
887 ndmp2_unix_file_stat fstat;
890 struct ndmp2_fh_add_unix_path_request
892 ndmp2_fh_unix_path paths<>;
896 /* NDMP2_FH_ADD_UNIX_DIR */
897 struct ndmp2_fh_unix_dir
899 ndmp2_unix_path name;
904 struct ndmp2_fh_add_unix_dir_request
906 ndmp2_fh_unix_dir dirs<>;
910 struct ndmp2_fh_unix_node
912 ndmp2_unix_file_stat fstat;
916 struct ndmp2_fh_add_unix_node_request
918 ndmp2_fh_unix_node nodes<>;
923 /****************************************************************
925 * End of file : ndmp.x
927 ****************************************************************/
928 %#endif /* !NDMOS_OPTION_NO_NDMP2 */