1 /*
2  * Copyright (c) 2000
3  *      Traakan, Inc., Los Altos, CA
4  *      All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice unmodified, this list of conditions, and the following
11  *    disclaimer.
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.
15  *
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
26  * SUCH DAMAGE.
27  */
28 
29 /*
30  * Project:  NDMJOB
31  * Ident:    $Id: $
32  *
33  * Description:
34  *
35  */
36 
37 
38 /*
39  * Copyright (c) 1997 Network Appliance. All Rights Reserved.
40  *
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.
45  *
46  * These notices must be retained in any copies of any part of this
47  * documentation and/or software.
48  *
49  */
50 
51 %#if __clang__
52 %#pragma clang diagnostic ignored "-Wunused-variable"
53 %#pragma clang diagnostic ignored "-Wunused-const-variable"
54 %#elif __GNUC__
55 %#if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 402
56 %#pragma GCC diagnostic ignored "-Wunused-variable"
57 %#endif
58 %#endif
59 
60 %#ifndef NDMOS_OPTION_NO_NDMP2
61 
62 const NDMP2VER = 2;
63 const NDMP2PORT = 10000;
64 
65 %#define ndmp2_u_quad uint64_t
66 %extern bool_t xdr_ndmp2_u_quad(register XDR *xdrs, ndmp2_u_quad *objp);
67 
68 struct _ndmp2_u_quad
69 {
70         uint32_t        high;
71         uint32_t        low;
72 };
73 
74 struct ndmp2_pval
75 {
76         string          name<>;
77         string          value<>;
78 };
79 
80 struct ndmp2_scsi_device
81 {
82         string          name<>;
83 };
84 
85 struct ndmp2_tape_device
86 {
87         string          name<>;
88 };
89 
90 enum ndmp2_error
91 {
92         NDMP2_NO_ERR,                   /* No error */
93         NDMP2_NOT_SUPPORTED_ERR,        /* Call is not supported */
94         NDMP2_DEVICE_BUSY_ERR,          /* The device is in use */
95         NDMP2_DEVICE_OPENED_ERR,        /* Another tape or scsi device
96                                          * is already open */
97         NDMP2_NOT_AUTHORIZED_ERR,       /* connection has not been authorized*/
98         NDMP2_PERMISSION_ERR,           /* some sort of permission problem */
99         NDMP2_DEV_NOT_OPEN_ERR,         /* SCSI device is not open */
100         NDMP2_IO_ERR,                   /* I/O error */
101         NDMP2_TIMEOUT_ERR,              /* command timed out */
102         NDMP2_ILLEGAL_ARGS_ERR,         /* illegal arguments in request */
103         NDMP2_NO_TAPE_LOADED_ERR,       /* Cannot open because there is
104                                            no tape loaded */
105         NDMP2_WRITE_PROTECT_ERR,        /* tape cannot be open for write */
106         NDMP2_EOF_ERR,                  /* Command encountered EOF */
107         NDMP2_EOM_ERR,                  /* Command encountered EOM */
108         NDMP2_FILE_NOT_FOUND_ERR,       /* File not found during restore */
109         NDMP2_BAD_FILE_ERR,             /* The file descriptor is invalid */
110         NDMP2_NO_DEVICE_ERR,            /* The device is not at that target */
111         NDMP2_NO_BUS_ERR,               /* Invalid controller */
112         NDMP2_XDR_DECODE_ERR,           /* Can't decode the request argument */
113         NDMP2_ILLEGAL_STATE_ERR,        /* Call can't be done at this state */
114         NDMP2_UNDEFINED_ERR,            /* Undefined Error */
115         NDMP2_XDR_ENCODE_ERR,           /* Can't encode the reply argument */
116         NDMP2_NO_MEM_ERR                /* no memory */
117 };
118 
119 enum ndmp2_header_message_type
120 {
121         NDMP2_MESSAGE_REQUEST,
122         NDMP2_MESSAGE_REPLY
123 };
124 
125 enum ndmp2_message
126 {
127         NDMP2_CONNECT_OPEN = 0x900,     /* CONNECT INTERFACE */
128         NDMP2_CONNECT_CLIENT_AUTH,
129         NDMP2_CONNECT_CLOSE,
130         NDMP2_CONNECT_SERVER_AUTH,
131 
132         NDMP2_CONFIG_GET_HOST_INFO = 0x100, /* CONFIG INTERFACE */
133         NDMP2_CONFIG_GET_BUTYPE_ATTR,
134         NDMP2_CONFIG_GET_MOVER_TYPE,
135         NDMP2_CONFIG_GET_AUTH_ATTR,
136 
137         NDMP2_SCSI_OPEN = 0x200,        /* SCSI INTERFACE */
138         NDMP2_SCSI_CLOSE,
139         NDMP2_SCSI_GET_STATE,
140         NDMP2_SCSI_SET_TARGET,
141         NDMP2_SCSI_RESET_DEVICE,
142         NDMP2_SCSI_RESET_BUS,
143         NDMP2_SCSI_EXECUTE_CDB,
144 
145         NDMP2_TAPE_OPEN = 0x300,        /* TAPE INTERFACE */
146         NDMP2_TAPE_CLOSE,
147         NDMP2_TAPE_GET_STATE,
148         NDMP2_TAPE_MTIO,
149         NDMP2_TAPE_WRITE,
150         NDMP2_TAPE_READ,
151         NDMP2_TAPE_RESVD1,
152         NDMP2_TAPE_EXECUTE_CDB,
153 
154         NDMP2_DATA_GET_STATE = 0x400,   /* DATA INTERFACE */
155         NDMP2_DATA_START_BACKUP,
156         NDMP2_DATA_START_RECOVER,
157         NDMP2_DATA_ABORT,
158         NDMP2_DATA_GET_ENV,
159         NDMP2_DATA_RESVD1,
160         NDMP2_DATA_RESVD2,
161         NDMP2_DATA_STOP,
162         NDMP2_DATA_START_RECOVER_FILEHIST = 0x40b, /* same as V3.1 */
163 
164         NDMP2_NOTIFY_RESVD1 = 0x500,    /* NOTIFY INTERFACE */
165         NDMP2_NOTIFY_DATA_HALTED,
166         NDMP2_NOTIFY_CONNECTED,
167         NDMP2_NOTIFY_MOVER_HALTED,
168         NDMP2_NOTIFY_MOVER_PAUSED,
169         NDMP2_NOTIFY_DATA_READ,
170 
171         NDMP2_LOG_LOG = 0x600,          /* LOGGING INTERFACE */
172         NDMP2_LOG_DEBUG,
173         NDMP2_LOG_FILE,
174 
175         NDMP2_FH_ADD_UNIX_PATH = 0x700, /* FILE HISTORY INTERFACE */
176         NDMP2_FH_ADD_UNIX_DIR,
177         NDMP2_FH_ADD_UNIX_NODE,
178 
179         NDMP2_MOVER_GET_STATE = 0xa00,  /* MOVER INTERFACE */
180         NDMP2_MOVER_LISTEN,
181         NDMP2_MOVER_CONTINUE,
182         NDMP2_MOVER_ABORT,
183         NDMP2_MOVER_STOP,
184         NDMP2_MOVER_SET_WINDOW,
185         NDMP2_MOVER_READ,
186         NDMP2_MOVER_CLOSE,
187         NDMP2_MOVER_SET_RECORD_SIZE,
188 
189         NDMP2_RESERVED = 0xff00         /* Reserved for prototyping */
190 };
191 
192 struct ndmp2_header
193 {
194         uint32_t                sequence;       /* monotonically increasing */
195         uint32_t                time_stamp;     /* time stamp of message */
196         ndmp2_header_message_type message_type; /* what type of message */
197         ndmp2_message           message;        /* message number */
198         uint32_t                reply_sequence; /* reply is in response to */
199         ndmp2_error             error;          /* communications errors */
200 };
201 
202 /**********************/
203 /*  CONNECT INTERFACE */
204 /**********************/
205 /* NDMP2_CONNECT_OPEN */
206 struct ndmp2_connect_open_request
207 {
208         uint16_t        protocol_version;       /* the version of protocol supported */
209 };
210 
211 struct ndmp2_connect_open_reply
212 {
213         ndmp2_error     error;
214 };
215 
216 /* NDMP2_CONNECT_CLIENT_AUTH */
217 enum ndmp2_auth_type
218 {
219         NDMP2_AUTH_NONE,                /* no password is required */
220         NDMP2_AUTH_TEXT,                /* the clear text password */
221         NDMP2_AUTH_MD5                  /* md5 */
222 };
223 
224 struct ndmp2_auth_text
225 {
226         string          auth_id<>;
227         string          auth_password<>;
228 };
229 
230 struct ndmp2_auth_md5
231 {
232         string          auth_id<>;
233         opaque          auth_digest[16];
234 };
235 
236 union ndmp2_auth_data switch (enum ndmp2_auth_type auth_type)
237 {
238     case NDMP2_AUTH_NONE:
239         void;
240     case NDMP2_AUTH_TEXT:
241         ndmp2_auth_text auth_text;
242     case NDMP2_AUTH_MD5:
243         ndmp2_auth_md5  auth_md5;
244 };
245 
246 struct ndmp2_connect_client_auth_request
247 {
248         ndmp2_auth_data auth_data;
249 };
250 
251 struct ndmp2_connect_client_auth_reply
252 {
253         ndmp2_error     error;
254 };
255 
256 /* NDMP2_CONNECT_CLOSE */
257 /* no request arguments */
258 /* no reply arguments */
259 
260 /* NDMP2_CONNECT_SERVER_AUTH */
261 union ndmp2_auth_attr switch (enum ndmp2_auth_type auth_type)
262 {
263     case NDMP2_AUTH_NONE:
264         void;
265     case NDMP2_AUTH_TEXT:
266         void;
267     case NDMP2_AUTH_MD5:
268         opaque  challenge[64];
269 };
270 
271 struct ndmp2_connect_server_auth_request
272 {
273         ndmp2_auth_attr client_attr;
274 };
275 
276 struct ndmp2_connect_server_auth_reply
277 {
278         ndmp2_error     error;
279         ndmp2_auth_data auth_result;
280 };
281 
282 /********************/
283 /* CONFIG INTERFACE */
284 /********************/
285 /* NDMP2_CONFIG_GET_HOST_INFO */
286 /* no request arguments */
287 struct ndmp2_config_get_host_info_reply
288 {
289         ndmp2_error     error;
290         string          hostname<>;     /* host name */
291         string          os_type<>;      /* The O/S type (e.g. SOLARIS) */
292         string          os_vers<>;      /* The O/S version (e.g. 2.5) */
293         string          hostid<>;
294         ndmp2_auth_type auth_type<>;
295 };
296 
297 /* NDMP2_CONFIG_GET_BUTYPE_ATTR */
298 const NDMP2_NO_BACKUP_FILELIST  = 0x0001;
299 const NDMP2_NO_BACKUP_FHINFO    = 0x0002;
300 const NDMP2_NO_RECOVER_FILELIST = 0x0004;
301 const NDMP2_NO_RECOVER_FHINFO   = 0x0008;
302 const NDMP2_NO_RECOVER_RESVD    = 0x0010;
303 const NDMP2_NO_RECOVER_INC_ONLY = 0x0020;
304 
305 struct ndmp2_config_get_butype_attr_request
306 {
307         string          name<>;         /* backup type name */
308 };
309 
310 struct ndmp2_config_get_butype_attr_reply
311 {
312         ndmp2_error     error;
313         uint32_t        attrs;
314 };
315 
316 /* NDMP2_CONFIG_GET_MOVER_TYPE */
317 /* no request arguments */
318 enum ndmp2_mover_addr_type
319 {
320         NDMP2_ADDR_LOCAL,
321         NDMP2_ADDR_TCP
322 };
323 
324 struct ndmp2_config_get_mover_type_reply
325 {
326         ndmp2_error             error;
327         ndmp2_mover_addr_type   methods<>;
328 };
329 
330 /* NDMP2_CONFIG_GET_AUTH_ATTR */
331 struct ndmp2_config_get_auth_attr_request
332 {
333         ndmp2_auth_type auth_type;
334 };
335 
336 struct ndmp2_config_get_auth_attr_reply
337 {
338         ndmp2_error     error;
339         ndmp2_auth_attr server_attr;
340 };
341 
342 /******************/
343 /* SCSI INTERFACE */
344 /******************/
345 /* NDMP2_SCSI_OPEN */
346 struct ndmp2_scsi_open_request
347 {
348         ndmp2_scsi_device device;
349 };
350 
351 struct ndmp2_scsi_open_reply
352 {
353         ndmp2_error     error;
354 };
355 
356 /* NDMP2_SCSI_CLOSE */
357 /* no request arguments */
358 struct ndmp2_scsi_close_reply
359 {
360         ndmp2_error     error;
361 };
362 
363 /* NDMP2_SCSI_GET_STATE */
364 /* no request arguments */
365 struct ndmp2_scsi_get_state_reply
366 {
367         ndmp2_error     error;
368         short           target_controller;
369         short           target_id;
370         short           target_lun;
371 };
372 
373 /* NDMP2_SCSI_SET_TARGET */
374 struct ndmp2_scsi_set_target_request
375 {
376         ndmp2_scsi_device device;
377         uint16_t        target_controller;
378         uint16_t        target_id;
379         uint16_t        target_lun;
380 };
381 
382 struct ndmp2_scsi_set_target_reply
383 {
384         ndmp2_error     error;
385 };
386 
387 /* NDMP2_SCSI_RESET_DEVICE */
388 /* no request arguments */
389 struct ndmp2_scsi_reset_device_reply
390 {
391         ndmp2_error     error;
392 };
393 
394 /* NDMP2_SCSI_RESET_BUS */
395 /* no request arguments */
396 struct ndmp2_scsi_reset_bus_reply
397 {
398         ndmp2_error     error;
399 };
400 
401 /* NDMP2_SCSI_EXECUTE_CDB */
402 const NDMP2_SCSI_DATA_IN  = 0x00000001; /* Expect data from SCSI device */
403 const NDMP2_SCSI_DATA_OUT = 0x00000002; /* Transfer data to SCSI device */
404 
405 struct ndmp2_execute_cdb_request
406 {
407         uint32_t        flags;
408         uint32_t        timeout;
409         uint32_t        datain_len;     /* Set for expected datain */
410         opaque          cdb<>;
411         opaque          dataout<>;
412 };
413 
414 struct ndmp2_execute_cdb_reply
415 {
416         ndmp2_error     error;
417         u_char          status;         /* SCSI status bytes */
418         uint32_t        dataout_len;
419         opaque          datain<>;       /* SCSI datain */
420         opaque          ext_sense<>;    /* Extended sense data */
421 };
422 typedef ndmp2_execute_cdb_request       ndmp2_scsi_execute_cdb_request;
423 typedef ndmp2_execute_cdb_reply         ndmp2_scsi_execute_cdb_reply;
424 
425 
426 /******************/
427 /* TAPE INTERFACE */
428 /******************/
429 /* NDMP2_TAPE_OPEN */
430 enum ndmp2_tape_open_mode
431 {
432         NDMP2_TAPE_READ_MODE,
433         NDMP2_TAPE_WRITE_MODE
434 };
435 
436 struct ndmp2_tape_open_request
437 {
438         ndmp2_tape_device       device;
439         ndmp2_tape_open_mode    mode;
440 };
441 
442 struct ndmp2_tape_open_reply
443 {
444         ndmp2_error     error;
445 };
446 
447 /* NDMP2_TAPE_CLOSE */
448 /* no request arguments */
449 struct ndmp2_tape_close_reply
450 {
451         ndmp2_error     error;
452 };
453 
454 /* NDMP2_TAPE_GET_STATE */
455 /* no request arguments */
456 const NDMP2_TAPE_NOREWIND = 0x0008;     /* non-rewind device */
457 const NDMP2_TAPE_WR_PROT  = 0x0010;     /* write-protected */
458 const NDMP2_TAPE_ERROR    = 0x0020;     /* media error */
459 const NDMP2_TAPE_UNLOAD   = 0x0040;     /* tape will be unloaded when
460                                          * the device is closed */
461 struct ndmp2_tape_get_state_reply
462 {
463         ndmp2_error     error;
464         uint32_t        flags;
465         uint32_t        file_num;
466         uint32_t        soft_errors;
467         uint32_t        block_size;
468         uint32_t        blockno;
469         ndmp2_u_quad    total_space;
470         ndmp2_u_quad    space_remain;
471 };
472 
473 /* NDMP2_TAPE_MTIO */
474 enum ndmp2_tape_mtio_op
475 {
476         NDMP2_MTIO_FSF,
477         NDMP2_MTIO_BSF,
478         NDMP2_MTIO_FSR,
479         NDMP2_MTIO_BSR,
480         NDMP2_MTIO_REW,
481         NDMP2_MTIO_EOF,
482         NDMP2_MTIO_OFF
483 };
484 
485 struct ndmp2_tape_mtio_request
486 {
487         ndmp2_tape_mtio_op      tape_op;
488         uint32_t                count;
489 };
490 
491 struct ndmp2_tape_mtio_reply
492 {
493         ndmp2_error     error;
494         uint32_t        resid_count;
495 };
496 
497 /* NDMP2_TAPE_WRITE */
498 struct ndmp2_tape_write_request
499 {
500         opaque          data_out<>;
501 };
502 
503 struct ndmp2_tape_write_reply
504 {
505         ndmp2_error     error;
506         uint32_t        count;
507 };
508 
509 /* NDMP2_TAPE_READ */
510 struct ndmp2_tape_read_request
511 {
512         uint32_t        count;
513 };
514 
515 struct ndmp2_tape_read_reply
516 {
517         ndmp2_error     error;
518         opaque          data_in<>;
519 };
520 
521 /* NDMP2_TAPE_EXECUTE_CDB */
522 typedef ndmp2_execute_cdb_request       ndmp2_tape_execute_cdb_request;
523 typedef ndmp2_execute_cdb_reply         ndmp2_tape_execute_cdb_reply;
524 
525 /********************************/
526 /* MOVER INTERFACE              */
527 /********************************/
528 /* NDMP2_MOVER_GET_STATE */
529 enum ndmp2_mover_state
530 {
531         NDMP2_MOVER_STATE_IDLE,
532         NDMP2_MOVER_STATE_LISTEN,
533         NDMP2_MOVER_STATE_ACTIVE,
534         NDMP2_MOVER_STATE_PAUSED,
535         NDMP2_MOVER_STATE_HALTED
536 };
537 
538 enum ndmp2_mover_pause_reason
539 {
540         NDMP2_MOVER_PAUSE_NA,
541         NDMP2_MOVER_PAUSE_EOM,
542         NDMP2_MOVER_PAUSE_EOF,
543         NDMP2_MOVER_PAUSE_SEEK,
544         NDMP2_MOVER_PAUSE_MEDIA_ERROR
545 };
546 
547 enum ndmp2_mover_halt_reason
548 {
549         NDMP2_MOVER_HALT_NA,
550         NDMP2_MOVER_HALT_CONNECT_CLOSED,
551         NDMP2_MOVER_HALT_ABORTED,
552         NDMP2_MOVER_HALT_INTERNAL_ERROR,
553         NDMP2_MOVER_HALT_CONNECT_ERROR
554 };
555 
556 /* no request arguments */
557 struct ndmp2_mover_get_state_reply
558 {
559         ndmp2_error             error;
560         ndmp2_mover_state       state;
561         ndmp2_mover_pause_reason pause_reason;
562         ndmp2_mover_halt_reason halt_reason;
563         uint32_t                record_size;
564         uint32_t                record_num;
565         ndmp2_u_quad            data_written;
566         ndmp2_u_quad            seek_position;
567         ndmp2_u_quad            bytes_left_to_read;
568         ndmp2_u_quad            window_offset;
569         ndmp2_u_quad            window_length;
570 };
571 
572 /* NDMP2_MOVER_LISTEN */
573 enum ndmp2_mover_mode
574 {
575         NDMP2_MOVER_MODE_READ,  /* read from data conn; write to tape */
576         NDMP2_MOVER_MODE_WRITE, /* write to data conn; read from tape */
577         NDMP2_MOVER_MODE_DATA   /* write to data conn; read from data conn */
578 };
579 
580 struct ndmp2_mover_tcp_addr
581 {
582         uint32_t        ip_addr;
583         uint16_t        port;
584 };
585 
586 union ndmp2_mover_addr switch (ndmp2_mover_addr_type addr_type)
587 {
588     case NDMP2_ADDR_LOCAL:
589         void;
590     case NDMP2_ADDR_TCP:
591         ndmp2_mover_tcp_addr    addr;
592 };
593 
594 struct ndmp2_mover_listen_request
595 {
596         ndmp2_mover_mode        mode;
597         ndmp2_mover_addr_type   addr_type;
598 };
599 
600 struct ndmp2_mover_listen_reply
601 {
602         ndmp2_error             error;
603         ndmp2_mover_addr        mover;
604 };
605 
606 /* NDMP2_MOVER_SET_RECORD_SIZE */
607 struct ndmp2_mover_set_record_size_request
608 {
609         uint32_t        len;
610 };
611 
612 struct ndmp2_mover_set_record_size_reply
613 {
614         ndmp2_error     error;
615 };
616 
617 /* NDMP2_MOVER_SET_WINDOW */
618 struct ndmp2_mover_set_window_request
619 {
620         ndmp2_u_quad    offset;
621         ndmp2_u_quad    length;
622 };
623 
624 struct ndmp2_mover_set_window_reply
625 {
626         ndmp2_error     error;
627 };
628 
629 /* NDMP2_MOVER_CONTINUE */
630 /* no request arguments */
631 struct ndmp2_mover_continue_reply
632 {
633         ndmp2_error     error;
634 };
635 
636 /* NDMP2_MOVER_ABORT */
637 /* no request arguments */
638 struct ndmp2_mover_abort_reply
639 {
640         ndmp2_error     error;
641 };
642 
643 /* NDMP2_MOVER_STOP */
644 /* no request arguments */
645 struct ndmp2_mover_stop_reply
646 {
647         ndmp2_error     error;
648 };
649 
650 /* NDMP2_MOVER_READ */
651 struct ndmp2_mover_read_request
652 {
653         ndmp2_u_quad    offset;
654         ndmp2_u_quad    length;
655 };
656 
657 struct ndmp2_mover_read_reply
658 {
659         ndmp2_error     error;
660 };
661 
662 /* NDMP2_MOVER_CLOSE */
663 /* no request arguments */
664 struct ndmp2_mover_close_reply
665 {
666         ndmp2_error     error;
667 };
668 
669 /****************************/
670 /* DATA INTERFACE           */
671 /****************************/
672 /* NDMP2_DATA_GET_STATE */
673 /* no request arguments */
674 enum ndmp2_data_operation
675 {
676         NDMP2_DATA_OP_NOACTION,
677         NDMP2_DATA_OP_BACKUP,
678         NDMP2_DATA_OP_RESTORE,
679         NDMP2_DATA_OP_RESTORE_FILEHIST
680 };
681 
682 enum ndmp2_data_state
683 {
684         NDMP2_DATA_STATE_IDLE,
685         NDMP2_DATA_STATE_ACTIVE,
686         NDMP2_DATA_STATE_HALTED
687 };
688 
689 enum ndmp2_data_halt_reason
690 {
691         NDMP2_DATA_HALT_NA,
692         NDMP2_DATA_HALT_SUCCESSFUL,
693         NDMP2_DATA_HALT_ABORTED,
694         NDMP2_DATA_HALT_INTERNAL_ERROR,
695         NDMP2_DATA_HALT_CONNECT_ERROR
696 };
697 
698 struct ndmp2_data_get_state_reply
699 {
700         ndmp2_error             error;
701         ndmp2_data_operation    operation;
702         ndmp2_data_state        state;
703         ndmp2_data_halt_reason  halt_reason;
704         ndmp2_u_quad            bytes_processed;
705         ndmp2_u_quad            est_bytes_remain;
706         uint32_t                est_time_remain;
707         ndmp2_mover_addr        mover;
708         ndmp2_u_quad            read_offset;
709         ndmp2_u_quad            read_length;
710 };
711 
712 /* NDMP2_DATA_START_BACKUP */
713 struct ndmp2_data_start_backup_request
714 {
715         ndmp2_mover_addr mover;         /* mover to receive data */
716         string          bu_type<>;      /* backup method to use */
717         ndmp2_pval      env<>;          /* Parameters that may modify backup */
718 };
719 
720 struct ndmp2_data_start_backup_reply
721 {
722         ndmp2_error     error;
723 };
724 
725 /* NDMP2_DATA_START_RECOVER */
726 struct ndmp2_name
727 {
728         string          name<>;
729         string          dest<>;
730         uint16_t        ssid;
731         ndmp2_u_quad    fh_info;
732 };
733 
734 struct ndmp2_data_start_recover_request
735 {
736         ndmp2_mover_addr mover;
737         ndmp2_pval      env<>;
738         ndmp2_name      nlist<>;
739         string          bu_type<>;
740 };
741 
742 struct ndmp2_data_start_recover_reply
743 {
744         ndmp2_error     error;
745 };
746 
747 /* NDMP2_DATA_START_RECOVER_FILEHIST */
748 typedef ndmp2_data_start_recover_request ndmp2_data_start_recover_filehist_request;
749 typedef ndmp2_data_start_recover_reply ndmp2_data_start_recover_filehist_reply;
750 
751 /* NDMP2_DATA_ABORT */
752 /* no request arguments */
753 struct ndmp2_data_abort_reply
754 {
755         ndmp2_error     error;
756 };
757 
758 /* NDMP2_DATA_STOP */
759 /* no request arguments */
760 struct ndmp2_data_stop_reply
761 {
762         ndmp2_error     error;
763 };
764 
765 /* NDMP2_DATA_GET_ENV */
766 /* no request arguments */
767 struct ndmp2_data_get_env_reply
768 {
769         ndmp2_error     error;
770         ndmp2_pval      env<>;
771 };
772 
773 /****************************/
774 /* NOTIFY INTERFACE         */
775 /****************************/
776 /* NDMP2_NOTIFY_DATA_HALTED */
777 struct ndmp2_notify_data_halted_request
778 {
779         ndmp2_data_halt_reason  reason;
780         string                  text_reason<>;
781 };
782 
783 /* No reply */
784 
785 /* NDMP2_NOTIFY_CONNECTED */
786 enum ndmp2_connect_reason
787 {
788         NDMP2_CONNECTED,        /* Connect sucessfully */
789         NDMP2_SHUTDOWN,         /* Connection shutdown */
790         NDMP2_REFUSED           /* reach the maximum number of connections */
791 };
792 
793 struct ndmp2_notify_connected_request
794 {
795         ndmp2_connect_reason    reason;
796         uint16_t                protocol_version;
797         string                  text_reason<>;
798 };
799 
800 /* NDMP2_NOTIFY_MOVER_PAUSED */
801 struct ndmp2_notify_mover_paused_request
802 {
803         ndmp2_mover_pause_reason reason;
804         ndmp2_u_quad            seek_position;
805 };
806 /* No reply */
807 
808 /* NDMP2_NOTIFY_MOVER_HALTED */
809 struct ndmp2_notify_mover_halted_request
810 {
811         ndmp2_mover_halt_reason reason;
812         string                  text_reason<>;
813 };
814 /* No reply */
815 
816 /* NDMP2_NOTIFY_DATA_READ */
817 struct ndmp2_notify_data_read_request
818 {
819         ndmp2_u_quad    offset;
820         ndmp2_u_quad    length;
821 };
822 /* No reply */
823 
824 /********************************/
825 /* LOG INTERFACE                                */
826 /********************************/
827 /* NDMP2_LOG_LOG */
828 struct ndmp2_log_log_request
829 {
830         string          entry<>;
831 };
832 /* No reply */
833 
834 /* NDMP2_LOG_DEBUG */
835 enum ndmp2_debug_level
836 {
837         NDMP2_DBG_USER_INFO,
838         NDMP2_DBG_USER_SUMMARY,
839         NDMP2_DBG_USER_DETAIL,
840         NDMP2_DBG_DIAG_INFO,
841         NDMP2_DBG_DIAG_SUMMARY,
842         NDMP2_DBG_DIAG_DETAIL,
843         NDMP2_DBG_PROG_INFO,
844         NDMP2_DBG_PROG_SUMMARY,
845         NDMP2_DBG_PROG_DETAIL
846 };
847 
848 struct ndmp2_log_debug_request
849 {
850         ndmp2_debug_level level;
851         string          message<>;
852 };
853 /* No reply */
854 
855 /* NDMP2_LOG_FILE */
856 struct ndmp2_log_file_request
857 {
858         string          name<>;
859         uint16_t        ssid;
860         ndmp2_error     error;
861 };
862 /* No reply */
863 
864 /********************************/
865 /* File History INTERFACE           */
866 /********************************/
867 /* NDMP2_FH_ADD_UNIX_PATH */
868 typedef string ndmp2_unix_path<>;
869 enum ndmp2_unix_file_type
870 {
871         NDMP2_FILE_DIR,
872         NDMP2_FILE_FIFO,
873         NDMP2_FILE_CSPEC,
874         NDMP2_FILE_BSPEC,
875         NDMP2_FILE_REG,
876         NDMP2_FILE_SLINK,
877         NDMP2_FILE_SOCK
878 };
879 
880 struct ndmp2_unix_file_stat
881 {
882         ndmp2_unix_file_type    ftype;
883         uint32_t                mtime;
884         uint32_t                atime;
885         uint32_t                ctime;
886         uint32_t                uid;
887         uint32_t                gid;
888         uint32_t                mode;
889         ndmp2_u_quad            size;
890         ndmp2_u_quad            fh_info;
891 };
892 
893 struct ndmp2_fh_unix_path
894 {
895         ndmp2_unix_path         name;
896         ndmp2_unix_file_stat    fstat;
897 };
898 
899 struct ndmp2_fh_add_unix_path_request
900 {
901         ndmp2_fh_unix_path      paths<>;
902 };
903 /* No reply */
904 
905 /* NDMP2_FH_ADD_UNIX_DIR */
906 struct ndmp2_fh_unix_dir
907 {
908         ndmp2_unix_path         name;
909         uint32_t                node;
910         uint32_t                parent;
911 };
912 
913 struct ndmp2_fh_add_unix_dir_request
914 {
915         ndmp2_fh_unix_dir       dirs<>;
916 };
917 /* No reply */
918 
919 struct ndmp2_fh_unix_node
920 {
921         ndmp2_unix_file_stat    fstat;
922         uint32_t                node;
923 };
924 
925 struct ndmp2_fh_add_unix_node_request
926 {
927         ndmp2_fh_unix_node      nodes<>;
928 };
929 /* No reply */
930 
931 
932 /****************************************************************
933 *
934 *       End of file     :       ndmp.x
935 *
936 ****************************************************************/
937 %#endif /* !NDMOS_OPTION_NO_NDMP2 */
938