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