Imported Upstream version 3.1.0
[debian/amanda] / ndmp-src / ndmp9.x
1 /*
2  * Copyright (c) 2000,2001
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  *      NDMPv9, represented here, is a ficticious version
35  *      used internally and never over-the-wire. This
36  *      isolates higher-level routines from variations
37  *      between NDMP protocol version. At this time,
38  *      NDMPv2, NDMPv3 and NDMPv4 are deployed. NDMPv9 tends
39  *      to be bits and pieces of all supported protocol versions
40  *      mashed together.
41  *
42  *      While we want the higher-level routines isolated,
43  *      for clarity we still want them to use data structures
44  *      and construct that resemble NDMP. Higher-level routines
45  *      manipulate NDMPv9 data structures. Mid-level routines
46  *      translate between NDMPv9 and the over-the-wire version
47  *      in use. Low-level routines do the over-the-wire functions.
48  *
49  *      The approach of using the latest version internally
50  *      and retrofiting earlier versions was rejected for
51  *      two reasons. First, it means a tear-up of higher-level
52  *      functions as new versions are deployed. Second,
53  *      it makes building with selected version impossible.
54  *      No matter what approach is taken, there will be
55  *      some sort of retrofit between versions. NDMPv9
56  *      is simply the internal version, and all bona-fide
57  *      versions are retrofitted. v9 was chosen because
58  *      it is unlikely the NDMP version will reach 9
59  *      within the useful life of the NDMP architecture.
60  *
61  *      NDMPv9 could be implemented in a hand-crafted header (.h)
62  *      file, yet we continue to use the ONC RPC (.x) description
63  *      for convenvience. It's easy to cut-n-paste from the other
64  *      NDMP.x files. It's important that ndmp9_xdr.c never be
65  *      generated nor compiled.
66  */
67
68
69 /*
70  * (from ndmp3.x)
71  * ndmp.x
72  *
73  * Description   : NDMP protocol rpcgen file.
74  *
75  * Copyright (c) 1999 Intelliguard Software, Network Appliance.
76  * All Rights Reserved.
77  */
78
79 /*
80  * (from ndmp2.x)
81  * Copyright (c) 1997 Network Appliance. All Rights Reserved.
82  *
83  * Network Appliance makes no representations concerning either
84  * the merchantability of this software or the suitability of this
85  * software for any particular purpose. It is provided "as is"
86  * without express or implied warranty of any kind.
87  *
88  * These notices must be retained in any copies of any part of this
89  * documentation and/or software.
90  */
91
92
93 const NDMP9VER = 9;
94
95
96 /*
97  * General types
98  ****************************************************************
99  */
100
101 /*
102  * Error codes
103  */
104 enum ndmp9_error {
105         NDMP9_NO_ERR,                   /* No error */
106         NDMP9_NOT_SUPPORTED_ERR,        /* Call is not supported */
107         NDMP9_DEVICE_BUSY_ERR,          /* The device is in use */
108         NDMP9_DEVICE_OPENED_ERR,        /* Another tape or scsi device
109                                          * is already open */
110         NDMP9_NOT_AUTHORIZED_ERR,       /* connection has not been authorized*/
111         NDMP9_PERMISSION_ERR,           /* some sort of permission problem */
112         NDMP9_DEV_NOT_OPEN_ERR,         /* SCSI device is not open */
113         NDMP9_IO_ERR,                   /* I/O error */
114         NDMP9_TIMEOUT_ERR,              /* command timed out */
115         NDMP9_ILLEGAL_ARGS_ERR,         /* illegal arguments in request */
116         NDMP9_NO_TAPE_LOADED_ERR,       /* Cannot open because there is
117                                            no tape loaded */
118         NDMP9_WRITE_PROTECT_ERR,        /* tape cannot be open for write */
119         NDMP9_EOF_ERR,                  /* Command encountered EOF */
120         NDMP9_EOM_ERR,                  /* Command encountered EOM */
121         NDMP9_FILE_NOT_FOUND_ERR,       /* File not found during recover */
122         NDMP9_BAD_FILE_ERR,             /* The file descriptor is invalid */
123         NDMP9_NO_DEVICE_ERR,            /* The device is not at that target */
124         NDMP9_NO_BUS_ERR,               /* Invalid controller */
125         NDMP9_XDR_DECODE_ERR,           /* Can't decode the request argument */
126         NDMP9_ILLEGAL_STATE_ERR,        /* Call can't be done at this state */
127         NDMP9_UNDEFINED_ERR,            /* Undefined Error */
128         NDMP9_XDR_ENCODE_ERR,           /* Can't encode the reply argument */
129         NDMP9_NO_MEM_ERR,               /* no memory */
130         NDMP9_CONNECT_ERR,              /* Error connecting to another
131                                          * NDMP server */
132         NDMP9_SEQUENCE_NUM_ERR,
133         NDMP9_READ_IN_PROGRESS_ERR      = 25,
134         NDMP9_PRECONDITION_ERR          = 26,
135         NDMP9_CLASS_NOT_SUPPORTED       = 27,
136         NDMP9_VERSION_NOT_SUPPORTED     = 28,
137         NDMP9_EXT_DUPL_CLASSES          = 29,
138         NDMP9_EXT_DN_ILLEGAL            = 30
139 };
140
141
142 /*
143  * Message codes
144  */
145 enum ndmp9_message {
146         NDMP9_CONNECT_OPEN = 0x900,     /* CONNECT INTERFACE */
147         NDMP9_CONNECT_CLIENT_AUTH = 0x901,
148         NDMP9_CONNECT_CLOSE = 0x902,
149         NDMP9_CONNECT_SERVER_AUTH = 0x903,
150
151         NDMP9_CONFIG_GET_HOST_INFO = 0x100, /* CONFIG INTERFACE */
152         NDMP9_CONFIG_GET_CONNECTION_TYPE = 0x102, /* NDMP2_CONFIG_GET_MOVER_TYPE on v2*/
153         NDMP9_CONFIG_GET_AUTH_ATTR = 0x103,
154         NDMP9_CONFIG_GET_BUTYPE_INFO = 0x104,   /* NDMPv3 and forward */
155         NDMP9_CONFIG_GET_FS_INFO = 0x105,       /* NDMPv3 and forward */
156         NDMP9_CONFIG_GET_TAPE_INFO = 0x106,     /* NDMPv3 and forward */
157         NDMP9_CONFIG_GET_SCSI_INFO = 0x107,     /* NDMPv3 and forward */
158         NDMP9_CONFIG_GET_SERVER_INFO =0x108,    /* NDMPv3 and forward */
159
160         NDMP9_SCSI_OPEN = 0x200,        /* SCSI INTERFACE */
161         NDMP9_SCSI_CLOSE = 0x201,
162         NDMP9_SCSI_GET_STATE = 0x202,
163         NDMP9_SCSI_SET_TARGET = 0x203,
164         NDMP9_SCSI_RESET_DEVICE = 0x204,
165         NDMP9_SCSI_RESET_BUS = 0x205,
166         NDMP9_SCSI_EXECUTE_CDB = 0x206,
167
168         NDMP9_TAPE_OPEN = 0x300,        /* TAPE INTERFACE */
169         NDMP9_TAPE_CLOSE = 0x301,
170         NDMP9_TAPE_GET_STATE = 0x302,
171         NDMP9_TAPE_MTIO = 0x303,
172         NDMP9_TAPE_WRITE = 0x304,
173         NDMP9_TAPE_READ = 0x305,
174         NDMP9_TAPE_EXECUTE_CDB = 0x307,
175
176         NDMP9_DATA_GET_STATE = 0x400,   /* DATA INTERFACE */
177         NDMP9_DATA_START_BACKUP = 0x401,
178         NDMP9_DATA_START_RECOVER = 0x402,
179         NDMP9_DATA_ABORT = 0x403,
180         NDMP9_DATA_GET_ENV = 0x404,
181         NDMP9_DATA_STOP = 0x407,
182         NDMP9_DATA_LISTEN = 0x409,
183         NDMP9_DATA_CONNECT = 0x40a,
184         NDMP9_DATA_START_RECOVER_FILEHIST = 0x40b,
185
186         NDMP9_NOTIFY_DATA_HALTED =0x501,/* NOTIFY INTERFACE */
187         NDMP9_NOTIFY_CONNECTED = 0x502,
188         NDMP9_NOTIFY_MOVER_HALTED = 0x503,
189         NDMP9_NOTIFY_MOVER_PAUSED = 0x504,
190         NDMP9_NOTIFY_DATA_READ =0x505,
191
192         NDMP9_LOG_FILE = 0x602,         /* LOGGING INTERFACE */
193         NDMP9_LOG_MESSAGE = 0x603,
194
195         NDMP9_FH_ADD_FILE = 0x703,      /* FILE HISTORY INTERFACE */
196         NDMP9_FH_ADD_DIR = 0x704,
197         NDMP9_FH_ADD_NODE = 0x705,
198
199         NDMP9_MOVER_GET_STATE = 0xa00,  /* MOVER INTERFACE */
200         NDMP9_MOVER_LISTEN = 0xa01,
201         NDMP9_MOVER_CONTINUE = 0xa02,
202         NDMP9_MOVER_ABORT = 0xa03,
203         NDMP9_MOVER_STOP = 0xa04,
204         NDMP9_MOVER_SET_WINDOW = 0xa05,
205         NDMP9_MOVER_READ = 0xa06,
206         NDMP9_MOVER_CLOSE =0xa07,
207         NDMP9_MOVER_SET_RECORD_SIZE =0xa08,
208         NDMP9_MOVER_CONNECT =0xa09
209 };
210
211
212 /*
213  * Common message bodies
214  */
215 %extern bool_t xdr_ndmp9_no_arguments();
216 %#define ndmp9_no_arguments int
217
218 struct ndmp9_just_error_reply {
219         ndmp9_error     error;
220 };
221
222
223 /*
224  * 64-bit integers
225  */
226 %extern bool_t xdr_ndmp9_u_quad();
227 %#define ndmp9_u_quad unsigned long long
228
229 /*
230  * Valid values. Sometimes we have values, and sometimes we don't.
231  */
232 enum ndmp9_validity {
233         NDMP9_VALIDITY_INVALID = 0,
234         NDMP9_VALIDITY_VALID,
235         NDMP9_VALIDITY_MAYBE_INVALID,
236         NDMP9_VALIDITY_MAYBE_VALID
237 };
238
239 %#define NDMP9_INVALID_U_LONG   0xFFFFFFFFul
240 struct ndmp9_valid_u_long {
241         ndmp9_validity  valid;
242         u_long          value;
243 };
244
245 %#define NDMP9_INVALID_U_QUAD   0xFFFFFFFFFFFFFFFFull
246 struct ndmp9_valid_u_quad {
247         ndmp9_validity  valid;
248         ndmp9_u_quad    value;
249 };
250
251
252 /*
253  * Property values. A simple name/value pair. Used in lots of places.
254  */
255 struct ndmp9_pval {
256         string          name<>;
257         string          value<>;
258 };
259
260
261 /*
262  * Authorization data. Three authorization types each
263  * with their particular values. Authorization is done
264  * in three steps:
265  *      1) Client determines which types of authorization are available
266  *         on the server.
267  *      2) Client may get parameters (challenge) from server.
268  *      3) Client requests authorization based on a shared
269  *         secret (password) with parameters (challenge) applied.
270  */
271 enum ndmp9_auth_type {
272         NDMP9_AUTH_NONE,                /* no password is required */
273         NDMP9_AUTH_TEXT,                /* the clear text password */
274         NDMP9_AUTH_MD5                  /* md5 */
275 };
276
277 union ndmp9_auth_attr switch (enum ndmp9_auth_type auth_type) {
278         case NDMP9_AUTH_NONE:
279                 void;
280         case NDMP9_AUTH_TEXT:
281                 void;
282         case NDMP9_AUTH_MD5:
283                 opaque  challenge[64];
284 };
285
286 struct ndmp9_auth_text {
287         string          auth_id<>;      /* account/user name */
288         string          auth_password<>; /* clear-text password */
289 };
290
291 struct ndmp9_auth_md5 {
292         string          auth_id<>;      /* account/user name */
293         opaque          auth_digest[16]; /* MD5 "hashed" password */
294 };
295
296 union ndmp9_auth_data switch (enum ndmp9_auth_type auth_type) {
297         case NDMP9_AUTH_NONE:
298                 void;
299         case NDMP9_AUTH_TEXT:
300                 struct ndmp9_auth_text  auth_text;
301         case NDMP9_AUTH_MD5:
302                 struct ndmp9_auth_md5   auth_md5;
303 };
304
305
306 /*
307  * The data connection (data stream, image stream, big ol' pipe)
308  * has two endpoints, Once side instigates the connection (connects),
309  * the other side receives the connection (listen/accept).
310  * Appears in DATA and MOVER interfaces.
311  */
312 enum ndmp9_addr_type {
313         NDMP9_ADDR_LOCAL,
314         NDMP9_ADDR_TCP,
315         /* IPC and FC addr types contemplated but never deployed */
316         NDMP9_ADDR_AS_CONNECTED = 0x1000
317 };
318
319 struct ndmp9_tcp_addr {
320         u_long          ip_addr;
321         u_short         port;
322 };
323
324 union ndmp9_addr switch (ndmp9_addr_type addr_type) {
325         case NDMP9_ADDR_LOCAL:
326         case NDMP9_ADDR_AS_CONNECTED:
327                 void;
328         case NDMP9_ADDR_TCP:
329                 ndmp9_tcp_addr  tcp_addr;
330 };
331
332
333
334
335 /*
336  * CONNECT INTERFACE
337  ****************************************************************
338  *
339  * The CONNECT INTERFACE is used to condition and authorize
340  * the control connection from the CONTROL Agent (DMA, Client)
341  * to the DATA, TAPE, or SCSI Agent (DSP, Servers).
342  *
343  * Most of this is addressed by NDMP0 (zero), which is a companion
344  * ficticious version. The NDMP0 features must never change to
345  * support protocol version negotiation. Once the version is
346  * negotiated, subsequent negotiations and authorization can
347  * take place.
348  */
349
350 /* NDMP9_CONNECT_OPEN -- must never change, negotiate protocol version */
351 struct ndmp9_connect_open_request {
352         u_short protocol_version;       /* the version of protocol supported */
353 };
354 typedef ndmp9_just_error_reply  ndmp9_connect_open_reply;
355
356 /* NDMP9_CONNECT_CLIENT_AUTH -- authorize client */
357 struct ndmp9_connect_client_auth_request {
358         ndmp9_auth_data auth_data;
359 };
360 typedef ndmp9_just_error_reply  ndmp9_connect_client_auth_reply;
361
362
363 /* NDMP9_CONNECT_CLOSE -- must never change, terminate control connection */
364 typedef ndmp9_no_arguments      ndmp9_connect_close_request;
365 typedef ndmp9_no_arguments      ndmp9_connect_close_reply;
366
367 /* NDMP9_CONNECT_SERVER_AUTH -- once client is authorized, ask server to
368  * prove itself -- nobody is using this */
369 struct ndmp9_connect_server_auth_request {
370         ndmp9_auth_attr         client_attr;
371 };
372
373 struct ndmp9_connect_server_auth_reply {
374         ndmp9_error             error;
375         ndmp9_auth_data         server_result;
376 };
377
378
379 /*
380  * CONFIG INTERFACE
381  ****************************************************************
382  *
383  * The CONFIG interfaces allow the CONTROL Agent (DMA, client) to
384  * obtain resource and other information from the DATA/TAPE/SCSI
385  * Agent (DSP, server).
386  *
387  * For NDMPv9, the whole show is lumped into a single data structure.
388  * The specific CONFIG interfaces, which vary between versions,
389  * pick-n-choose the info needed.
390  */
391
392 struct ndmp9_butype_info {
393         string                  butype_name<>;
394         ndmp9_valid_u_long      v2attr;
395         ndmp9_valid_u_long      v3attr;
396         ndmp9_valid_u_long      v4attr;
397         ndmp9_pval              default_env<>;
398 };
399
400 struct ndmp9_fs_info {
401         string                  fs_type<>;
402         string                  fs_logical_device<>;
403         string                  fs_physical_device<>;
404         ndmp9_valid_u_quad      total_size;
405         ndmp9_valid_u_quad      used_size;
406         ndmp9_valid_u_quad      avail_size;
407         ndmp9_valid_u_quad      total_inodes;
408         ndmp9_valid_u_quad      used_inodes;
409         ndmp9_pval              fs_env<>;
410         string                  fs_status<>;
411 };
412
413 struct ndmp9_device_capability {
414         string                  device<>;
415         ndmp9_valid_u_long      v3attr;
416         ndmp9_valid_u_long      v4attr;
417         ndmp9_pval              capability<>;
418 };
419
420 struct ndmp9_device_info {
421         string                  model<>;
422         ndmp9_device_capability caplist<>;
423 };
424
425 const NDMP9_CONFIG_CONNTYPE_LOCAL       = 0x0001;
426 const NDMP9_CONFIG_CONNTYPE_TCP         = 0x0002;
427
428 const NDMP9_CONFIG_AUTHTYPE_NONE        = 0x0001;
429 const NDMP9_CONFIG_AUTHTYPE_TEXT        = 0x0002;
430 const NDMP9_CONFIG_AUTHTYPE_MD5         = 0x0004;
431
432 struct ndmp9_config_info {
433         ndmp9_error             error;
434
435         /* ndmp[23]_config_get_host_info_reply */
436         string                  hostname<>; /* host name */
437         string                  os_type<>;  /* The O/S type (e.g. SOLARIS) */
438         string                  os_vers<>;  /* The O/S version (e.g. 2.5) */
439         string                  hostid<>;
440
441         /* ndmp[34]_config_get_server_info_reply */
442         string                  vendor_name<>;
443         string                  product_name<>;
444         string                  revision_number<>;
445
446         /* ndmp2_config_get_host_info */
447         /* ndmp[34]_config_get_server_info */
448         u_long                  authtypes;
449
450         /* ndmp2_config_get_mover_type */
451         /* ndmp[34]_config_get_connection_type */
452         u_long                  conntypes;
453
454         /* ndmp2_config_get_butype_attr */
455         /* ndmp[34]_config_get_butype_info */
456         ndmp9_butype_info       butype_info<>;
457
458         /* ndmp[34]_config_get_fs_info */
459         ndmp9_fs_info           fs_info<>;
460
461         /* ndmp[34]_config_get_tape_info */
462         ndmp9_device_info       tape_info<>;
463
464         /* ndmp[34]_config_get_scsi_info */
465         ndmp9_device_info       scsi_info<>;
466 };
467
468 /* NDMP9_CONFIG_GET_INFO */
469 typedef ndmp9_no_arguments      ndmp9_config_get_info_request;
470 struct ndmp9_config_get_info_reply {
471         ndmp9_error             error;
472         ndmp9_config_info       config_info;
473 };
474
475 /* NDMP9_CONFIG_GET_HOST_INFO */
476 typedef ndmp9_no_arguments      ndmp9_config_get_host_info_request;
477 typedef ndmp9_config_get_info_reply ndmp9_config_get_host_info_reply;
478
479 /* NDMP9_CONFIG_GET_CONNECTION_TYPE */
480 typedef ndmp9_no_arguments      ndmp9_config_get_connection_type_request;
481 typedef ndmp9_config_get_info_reply ndmp9_config_get_connection_type_reply;
482
483 /* NDMP9_CONFIG_GET_SERVER_INFO */
484 typedef ndmp9_no_arguments      ndmp9_config_get_server_info_request;
485 typedef ndmp9_config_get_info_reply ndmp9_config_get_server_info_reply;
486
487 /* NDMP9_CONFIG_GET_BUTYPE_INFO */
488 typedef ndmp9_no_arguments      ndmp9_config_get_butype_info_request;
489 typedef ndmp9_config_get_info_reply ndmp9_config_get_butype_info_reply;
490
491 /* NDMP9_CONFIG_GET_FS_INFO */
492 typedef ndmp9_no_arguments      ndmp9_config_get_fs_info_request;
493 typedef ndmp9_config_get_info_reply ndmp9_config_get_fs_info_reply;
494
495 /* NDMP9_CONFIG_GET_TAPE_INFO */
496 typedef ndmp9_no_arguments      ndmp9_config_get_tape_info_request;
497 typedef ndmp9_config_get_info_reply ndmp9_config_get_tape_info_reply;
498
499 /* NDMP9_CONFIG_GET_SCSI_INFO */
500 typedef ndmp9_no_arguments      ndmp9_config_get_scsi_info_request;
501 typedef ndmp9_config_get_info_reply ndmp9_config_get_scsi_info_reply;
502
503
504 /* NDMP9_CONFIG_GET_AUTH_ATTR */
505 struct ndmp9_config_get_auth_attr_request {
506         ndmp9_auth_type         auth_type;
507 };
508
509 struct ndmp9_config_get_auth_attr_reply {
510         ndmp9_error             error;
511         ndmp9_auth_attr         server_attr;
512 };
513
514
515
516 /*
517  * SCSI INTERFACE
518  ****************************************************************
519  *
520  * A SCSI pass-thru service. The CONTROL Agent (DMA, Client)
521  * manipulates a SCSI Media Changer through this interface.
522  * It may be used for other purposes.
523  */
524
525 /* NDMP9_SCSI_OPEN */
526 struct ndmp9_scsi_open_request {
527         string          device<>;
528 };
529 typedef ndmp9_just_error_reply  ndmp9_scsi_open_reply;
530
531 /* NDMP9_SCSI_CLOSE */
532 typedef ndmp9_no_arguments      ndmp9_scsi_close_request;
533 typedef ndmp9_just_error_reply  ndmp9_scsi_close_reply;
534
535 /* NDMP9_SCSI_GET_STATE */
536 typedef ndmp9_no_arguments      ndmp9_scsi_get_state_request;
537 struct ndmp9_scsi_get_state_reply {
538         ndmp9_error     error;
539         short           target_controller;
540         short           target_id;
541         short           target_lun;
542 };
543
544 /* NDMP9_SCSI_SET_TARGET -- deleted for NDMPv4 */
545 struct ndmp9_scsi_set_target_request {
546         string          device<>;
547         u_short         target_controller;
548         u_short         target_id;
549         u_short         target_lun;
550 };
551 typedef ndmp9_just_error_reply  ndmp9_scsi_set_target_reply;
552
553
554 /* NDMP9_SCSI_RESET_DEVICE */
555 typedef ndmp9_no_arguments      ndmp9_scsi_reset_device_request;
556 typedef ndmp9_just_error_reply  ndmp9_scsi_reset_device_reply;
557
558 /* NDMP9_SCSI_RESET_BUS -- deleted for NDMPv4 */
559 typedef ndmp9_no_arguments      ndmp9_scsi_reset_bus_request;
560 typedef ndmp9_just_error_reply  ndmp9_scsi_reset_bus_reply;
561
562
563 /* NDMP9_SCSI_EXECUTE_CDB */
564 enum ndmp9_scsi_data_dir {
565         NDMP9_SCSI_DATA_DIR_NONE = 0,
566         NDMP9_SCSI_DATA_DIR_IN = 1,     /* Expect data from SCSI device */
567         NDMP9_SCSI_DATA_DIR_OUT = 2     /* Transfer data to SCSI device */
568 };
569
570 struct ndmp9_execute_cdb_request {
571         ndmp9_scsi_data_dir     data_dir;
572         u_long                  timeout;
573         u_long                  datain_len;     /* Set for expected datain */
574         opaque                  cdb<>;
575         opaque                  dataout<>;
576 };
577
578 struct ndmp9_execute_cdb_reply {
579         ndmp9_error     error;
580         u_char          status;         /* SCSI status bytes */
581         u_long          dataout_len;
582         opaque          datain<>;       /* SCSI datain */
583         opaque          ext_sense<>;    /* Extended sense data */
584 };
585
586 typedef ndmp9_execute_cdb_request       ndmp9_scsi_execute_cdb_request;
587 typedef ndmp9_execute_cdb_reply         ndmp9_scsi_execute_cdb_reply;
588
589
590
591 /******************/
592 /* TAPE INTERFACE */
593 /******************/
594 /* NDMP9_TAPE_OPEN */
595 enum ndmp9_tape_open_mode {
596         NDMP9_TAPE_READ_MODE,
597         NDMP9_TAPE_RDWR_MODE,
598         NDMP9_TAPE_RAW_MODE             /* new for NDMPv4 */
599 };
600
601 enum ndmp9_tape_state {
602         NDMP9_TAPE_STATE_IDLE,          /* not doing anything */
603         NDMP9_TAPE_STATE_OPEN,          /* open, tape operations OK */
604         NDMP9_TAPE_STATE_MOVER          /* mover active, tape ops locked out */
605                                         /* ie read, write, mtio, close, cdb */
606 };
607
608 struct ndmp9_tape_open_request {
609         string                  device<>;
610         ndmp9_tape_open_mode    mode;
611 };
612 typedef ndmp9_just_error_reply  ndmp9_tape_open_reply;
613
614 /* NDMP9_TAPE_CLOSE */
615 typedef ndmp9_no_arguments      ndmp9_tape_close_request;
616 typedef ndmp9_just_error_reply  ndmp9_tape_close_reply;
617
618
619 /* NDMP9_TAPE_GET_STATE */
620 const NDMP9_TAPE_STATE_NOREWIND = 0x0008;       /* non-rewind device */
621 const NDMP9_TAPE_STATE_WR_PROT  = 0x0010;       /* write-protected */
622 const NDMP9_TAPE_STATE_ERROR    = 0x0020;       /* media error */
623 const NDMP9_TAPE_STATE_UNLOAD   = 0x0040;       /* tape will be unloaded when
624                                                  * the device is closed */
625
626 typedef ndmp9_no_arguments      ndmp9_tape_get_state_request;
627 struct ndmp9_tape_get_state_reply {
628         ndmp9_error             error;
629         u_long                  flags;          /* compatible NDMP[2349] */
630         ndmp9_tape_state        state;
631         ndmp9_tape_open_mode    open_mode;
632         ndmp9_valid_u_long      file_num;
633         ndmp9_valid_u_long      soft_errors;
634         ndmp9_valid_u_long      block_size;
635         ndmp9_valid_u_long      blockno;
636         ndmp9_valid_u_quad      total_space;
637         ndmp9_valid_u_quad      space_remain;
638         ndmp9_valid_u_long      partition;
639 };
640
641 /* NDMP9_TAPE_MTIO */
642 enum ndmp9_tape_mtio_op {
643         NDMP9_MTIO_FSF,
644         NDMP9_MTIO_BSF,
645         NDMP9_MTIO_FSR,
646         NDMP9_MTIO_BSR,
647         NDMP9_MTIO_REW,
648         NDMP9_MTIO_EOF,
649         NDMP9_MTIO_OFF
650 };
651
652 struct ndmp9_tape_mtio_request {
653         ndmp9_tape_mtio_op      tape_op;
654         u_long                  count;
655 };
656
657 struct ndmp9_tape_mtio_reply {
658         ndmp9_error     error;
659         u_long          resid_count;
660 };
661
662
663 /* NDMP9_TAPE_WRITE */
664 struct ndmp9_tape_write_request {
665         opaque          data_out<>;
666 };
667
668 struct ndmp9_tape_write_reply {
669         ndmp9_error     error;
670         u_long          count;
671 };
672
673
674 /* NDMP9_TAPE_READ */
675 struct ndmp9_tape_read_request {
676         u_long          count;
677 };
678
679 struct ndmp9_tape_read_reply {
680         ndmp9_error     error;
681         opaque          data_in<>;
682 };
683
684 /* NDMP9_TAPE_EXECUTE_CDB */
685 typedef ndmp9_execute_cdb_request       ndmp9_tape_execute_cdb_request;
686 typedef ndmp9_execute_cdb_reply         ndmp9_tape_execute_cdb_reply;
687
688
689
690
691 /********************************/
692 /* MOVER INTERFACE              */
693 /********************************/
694 enum ndmp9_mover_state {
695         NDMP9_MOVER_STATE_IDLE,
696         NDMP9_MOVER_STATE_LISTEN,
697         NDMP9_MOVER_STATE_ACTIVE,
698         NDMP9_MOVER_STATE_PAUSED,
699         NDMP9_MOVER_STATE_HALTED,
700         NDMP9_MOVER_STATE_STANDBY       /* awaiting mover_read_request */
701 };
702
703 enum ndmp9_mover_mode {
704         NDMP9_MOVER_MODE_READ,  /* read from data conn; write to tape */
705         NDMP9_MOVER_MODE_WRITE  /* write to data conn; read from tape */
706 };
707
708 enum ndmp9_mover_pause_reason {
709         NDMP9_MOVER_PAUSE_NA,
710         NDMP9_MOVER_PAUSE_EOM,
711         NDMP9_MOVER_PAUSE_EOF,
712         NDMP9_MOVER_PAUSE_SEEK,
713         NDMP9_MOVER_PAUSE_MEDIA_ERROR,
714         NDMP9_MOVER_PAUSE_EOW
715 };
716
717 enum ndmp9_mover_halt_reason {
718         NDMP9_MOVER_HALT_NA,
719         NDMP9_MOVER_HALT_CONNECT_CLOSED,
720         NDMP9_MOVER_HALT_ABORTED,
721         NDMP9_MOVER_HALT_INTERNAL_ERROR,
722         NDMP9_MOVER_HALT_CONNECT_ERROR,
723         NDMP9_MOVER_HALT_MEDIA_ERROR
724 };
725
726 /* NDMP9_MOVER_GET_STATE */
727 typedef ndmp9_no_arguments      ndmp9_mover_get_state_request;
728 struct ndmp9_mover_get_state_reply {
729         ndmp9_error             error;
730         ndmp9_mover_state       state;
731         ndmp9_mover_mode        mode;
732         ndmp9_mover_pause_reason pause_reason;
733         ndmp9_mover_halt_reason halt_reason;
734         u_long                  record_size;
735         u_long                  record_num;
736         ndmp9_u_quad            bytes_moved;
737         ndmp9_u_quad            seek_position;
738         ndmp9_u_quad            bytes_left_to_read;
739         ndmp9_u_quad            window_offset;
740         ndmp9_u_quad            window_length;
741         ndmp9_addr              data_connection_addr;
742 };
743
744 /* NDMP9_MOVER_LISTEN */
745 struct ndmp9_mover_listen_request {
746         ndmp9_mover_mode        mode;
747         ndmp9_addr_type         addr_type;
748 };
749
750 struct ndmp9_mover_listen_reply {
751         ndmp9_error             error;
752         ndmp9_addr              data_connection_addr;
753 };
754
755 /* NDMP9_MOVER_CONNECT */
756 struct ndmp9_mover_connect_request {
757         ndmp9_mover_mode        mode;
758         ndmp9_addr              addr;
759 };
760 typedef ndmp9_just_error_reply  ndmp9_mover_connect_reply;
761
762 /* NDMP9_MOVER_SET_RECORD_SIZE */
763 struct ndmp9_mover_set_record_size_request {
764         u_long                  record_size;
765 };
766 typedef ndmp9_just_error_reply  ndmp9_mover_set_record_size_reply;
767
768 /* NDMP9_MOVER_SET_WINDOW */
769 struct ndmp9_mover_set_window_request {
770         ndmp9_u_quad    offset;
771         ndmp9_u_quad    length;
772 };
773 typedef ndmp9_just_error_reply  ndmp9_mover_set_window_reply;
774
775 /* NDMP9_MOVER_CONTINUE */
776 typedef ndmp9_no_arguments      ndmp9_mover_continue_request;
777 typedef ndmp9_just_error_reply  ndmp9_mover_continue_reply;
778
779
780 /* NDMP9_MOVER_ABORT */
781 typedef ndmp9_no_arguments      ndmp9_mover_abort_request;
782 typedef ndmp9_just_error_reply  ndmp9_mover_abort_reply;
783
784 /* NDMP9_MOVER_STOP */
785 typedef ndmp9_no_arguments      ndmp9_mover_stop_request;
786 typedef ndmp9_just_error_reply  ndmp9_mover_stop_reply;
787
788 /* NDMP9_MOVER_READ */
789 struct ndmp9_mover_read_request {
790         ndmp9_u_quad    offset;
791         ndmp9_u_quad    length;
792 };
793 typedef ndmp9_just_error_reply  ndmp9_mover_read_reply;
794
795 /* NDMP9_MOVER_CLOSE */
796 typedef ndmp9_no_arguments      ndmp9_mover_close_request;
797 typedef ndmp9_just_error_reply  ndmp9_mover_close_reply;
798
799
800
801
802 /****************************/
803 /* DATA INTERFACE           */
804 /****************************/
805
806 enum ndmp9_data_operation {
807         NDMP9_DATA_OP_NOACTION,
808         NDMP9_DATA_OP_BACKUP,
809         NDMP9_DATA_OP_RECOVER,
810         NDMP9_DATA_OP_RECOVER_FILEHIST
811 };
812
813 enum ndmp9_data_state {
814         NDMP9_DATA_STATE_IDLE,
815         NDMP9_DATA_STATE_ACTIVE,
816         NDMP9_DATA_STATE_HALTED,
817         NDMP9_DATA_STATE_LISTEN,
818         NDMP9_DATA_STATE_CONNECTED
819 };
820
821 enum ndmp9_data_halt_reason {
822         NDMP9_DATA_HALT_NA,
823         NDMP9_DATA_HALT_SUCCESSFUL,
824         NDMP9_DATA_HALT_ABORTED,
825         NDMP9_DATA_HALT_INTERNAL_ERROR,
826         NDMP9_DATA_HALT_CONNECT_ERROR
827 };
828
829 /* NDMP9_DATA_START_BACKUP */
830 typedef ndmp9_no_arguments      ndmp9_data_get_state_request;
831 struct ndmp9_data_get_state_reply {
832         ndmp9_error             error;
833         ndmp9_data_operation    operation;
834         ndmp9_data_state        state;
835         ndmp9_data_halt_reason  halt_reason;
836         ndmp9_u_quad            bytes_processed;
837         ndmp9_valid_u_quad      est_bytes_remain;
838         ndmp9_valid_u_long      est_time_remain;
839         ndmp9_addr              data_connection_addr;
840         ndmp9_u_quad            read_offset;
841         ndmp9_u_quad            read_length;
842 };
843
844 struct ndmp9_name {
845         string                  original_path<>; /* relative to backup root */
846         string                  destination_path<>;
847         /* nt_destination_path<> */
848         ndmp9_valid_u_quad      fh_info;
849 };
850
851
852
853 /* NDMP9_DATA_START_BACKUP */
854 struct ndmp9_data_start_backup_request {
855         string          bu_type<>;      /* backup method to use */
856         ndmp9_pval      env<>;          /* Parameters that may modify backup */
857         ndmp9_addr      addr;
858 };
859 typedef ndmp9_just_error_reply  ndmp9_data_start_backup_reply;
860
861 /* NDMP9_DATA_START_RECOVER */
862 struct ndmp9_data_start_recover_request {
863         ndmp9_pval      env<>;
864         ndmp9_name      nlist<>;
865         string          bu_type<>;
866         ndmp9_addr      addr;
867 };
868 typedef ndmp9_just_error_reply  ndmp9_data_start_recover_reply;
869
870 /* NDMP9_DATA_START_RECOVER_FILEHIST */
871 typedef ndmp9_data_start_recover_request ndmp9_data_start_recover_filehist_request;
872 typedef ndmp9_data_start_recover_reply ndmp9_data_start_recover_filehist_reply;
873
874
875 /* NDMP9_DATA_ABORT */
876 typedef ndmp9_no_arguments      ndmp9_data_abort_request;
877 typedef ndmp9_just_error_reply  ndmp9_data_abort_reply;
878
879 /* NDMP9_DATA_STOP */
880 typedef ndmp9_no_arguments      ndmp9_data_stop_request;
881 typedef ndmp9_just_error_reply  ndmp9_data_stop_reply;
882
883 /* NDMP9_DATA_GET_ENV */
884 typedef ndmp9_no_arguments      ndmp9_data_get_env_request;
885 struct ndmp9_data_get_env_reply {
886         ndmp9_error     error;
887         ndmp9_pval      env<>;
888 };
889
890 /* NDMP9_DATA_LISTEN */
891 struct ndmp9_data_listen_request {
892         ndmp9_addr_type addr_type;
893 };
894
895 struct ndmp9_data_listen_reply {
896         ndmp9_error     error;
897         ndmp9_addr      data_connection_addr;
898 };
899
900 /* NDMP9_DATA_CONNECT */
901 struct ndmp9_data_connect_request {
902         ndmp9_addr      addr;
903 };
904 typedef ndmp9_just_error_reply  ndmp9_data_connect_reply;
905
906
907
908
909 /****************************/
910 /* NOTIFY INTERFACE         */
911 /****************************/
912
913 /* NDMP9_NOTIFY_DATA_HALTED */
914 struct ndmp9_notify_data_halted_request {
915         ndmp9_data_halt_reason  reason;
916 };
917
918 enum ndmp9_connect_reason {
919         NDMP9_CONNECTED,        /* Connect sucessfully */
920         NDMP9_SHUTDOWN,         /* Connection shutdown */
921         NDMP9_REFUSED           /* reach the maximum number of connections */
922 };
923
924 /* NDMP9_NOTIFY_CONNECTED */
925 struct ndmp9_notify_connected_request {
926         ndmp9_connect_reason    reason;
927         u_short                 protocol_version;
928         string                  text_reason<>;
929 };
930
931 /* NDMP9_NOTIFY_MOVER_HALTED */
932 struct ndmp9_notify_mover_halted_request {
933         ndmp9_mover_halt_reason reason;
934 };
935
936 /* NDMP9_NOTIFY_MOVER_PAUSED */
937 struct ndmp9_notify_mover_paused_request {
938         ndmp9_mover_pause_reason reason;
939         ndmp9_u_quad            seek_position;
940 };
941
942 /* NDMP9_NOTIFY_DATA_READ */
943 struct ndmp9_notify_data_read_request {
944         ndmp9_u_quad    offset;
945         ndmp9_u_quad    length;
946 };
947
948
949 /********************************/
950 /* LOG INTERFACE                */
951 /********************************/
952 /* NDMP9_LOG_MESSAGE */
953 enum ndmp9_log_type {
954         NDMP9_LOG_NORMAL,
955         NDMP9_LOG_DEBUG,
956         NDMP9_LOG_ERROR,
957         NDMP9_LOG_WARNING
958 };
959
960 struct ndmp9_log_message_request {
961         ndmp9_log_type          log_type;
962         u_long                  message_id;
963         string                  entry<>;
964         ndmp9_valid_u_long      associated_message_sequence;
965 };
966 /* No reply */
967
968 enum ndmp9_recovery_status {
969         NDMP9_RECOVERY_SUCCESSFUL             = 0,
970         NDMP9_RECOVERY_FAILED_PERMISSION      = 1,
971         NDMP9_RECOVERY_FAILED_NOT_FOUND       = 2,
972         NDMP9_RECOVERY_FAILED_NO_DIRECTORY    = 3,
973         NDMP9_RECOVERY_FAILED_OUT_OF_MEMORY   = 4,
974         NDMP9_RECOVERY_FAILED_IO_ERROR        = 5,
975         NDMP9_RECOVERY_FAILED_UNDEFINED_ERROR = 6
976 };
977
978 /* NDMP9_LOG_FILE */
979 struct ndmp9_log_file_request {
980         string                  name<>;
981         ndmp9_recovery_status   recovery_status;
982 };
983 /* No reply */
984
985
986
987 /*
988  * FILE HISTORY INTERFACES
989  ****************************************************************
990  */
991
992
993 enum ndmp9_file_type {
994         NDMP9_FILE_DIR,
995         NDMP9_FILE_FIFO,
996         NDMP9_FILE_CSPEC,
997         NDMP9_FILE_BSPEC,
998         NDMP9_FILE_REG,
999         NDMP9_FILE_SLINK,
1000         NDMP9_FILE_SOCK,
1001         NDMP9_FILE_REGISTRY,
1002         NDMP9_FILE_OTHER
1003 };
1004
1005 struct ndmp9_file_stat {
1006         ndmp9_file_type         ftype;
1007         ndmp9_valid_u_long      mtime;
1008         ndmp9_valid_u_long      atime;
1009         ndmp9_valid_u_long      ctime;
1010         ndmp9_valid_u_long      uid;
1011         ndmp9_valid_u_long      gid;
1012         ndmp9_valid_u_long      mode;
1013         ndmp9_valid_u_quad      size;
1014         ndmp9_valid_u_long      links;
1015
1016         /*
1017          * Add NT attributes here as ndmp9_valid_....
1018          */
1019
1020         ndmp9_valid_u_quad      node;       /* id on disk at backup time */
1021         ndmp9_valid_u_quad      fh_info;    /* id on tape at backup time */
1022 };
1023
1024
1025 /*
1026  * ndmp_fh_add_file
1027  * no reply
1028  */
1029 struct ndmp9_file {
1030         string                  unix_path<>;
1031         /* nt_path<> here */
1032         /* dos_path<> here */
1033         ndmp9_file_stat         fstat;
1034 };
1035
1036 struct ndmp9_fh_add_file_request {
1037         ndmp9_file              files<>;
1038 };
1039
1040
1041 /*
1042  * ndmp_fh_add_dir
1043  * no reply
1044  */
1045 struct ndmp9_dir {
1046         string                  unix_name<>;
1047         /* nt_name<> here */
1048         /* dos_name<> here */
1049         ndmp9_u_quad            node;
1050         ndmp9_u_quad            parent;
1051 };
1052
1053 struct ndmp9_fh_add_dir_request {
1054         ndmp9_dir               dirs<>;
1055 };
1056
1057
1058 /*
1059  * ndmp_fh_add_node
1060  * no reply
1061  */
1062 struct ndmp9_node {
1063         ndmp9_file_stat         fstat;
1064 };
1065
1066 struct ndmp9_fh_add_node_request {
1067         ndmp9_node              nodes<>;
1068 };
1069 /* No reply */