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 * NDMPv0, represented here, is a ficticious version 35 * used to negotiate NDMP protocol version for the 36 * remainder of the session. Early, as a connection is 37 * being set up, the version of the protocol is unknown. 38 * The first messages exchanged negotiate the protocol 39 * version, and such messages are in the NDMP format. 40 * This is different than other protocols, such as ONC RPC 41 * which negotiate version by lower layers before the 42 * objective protocol becomes involved. During the 43 * negotiation, we deem the connection to be in "v0" mode. 44 * This NDMPv0 protocol specification is the subset of 45 * the NDMP protocol(s) required for the negotiation, 46 * and necessarily must remain immutable for all time. 47 */ 48 49 50 /* 51 * Copyright (c) 1997 Network Appliance. All Rights Reserved. 52 * 53 * Network Appliance makes no representations concerning either 54 * the merchantability of this software or the suitability of this 55 * software for any particular purpose. It is provided "as is" 56 * without express or implied warranty of any kind. 57 * 58 * These notices must be retained in any copies of any part of this 59 * documentation and/or software. 60 * 61 */ 62 %#if __clang__ 63 %#pragma clang diagnostic ignored "-Wunused-variable" 64 %#pragma clang diagnostic ignored "-Wunused-const-variable" 65 %#elif __GNUC__ 66 %#if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 402 67 %#pragma GCC diagnostic ignored "-Wunused-variable" 68 %#endif 69 %#endif 70 71 const NDMPPORT = 10000; 72 73 enum ndmp0_error 74 { 75 NDMP0_NO_ERR, /* No error */ 76 NDMP0_NOT_SUPPORTED_ERR, /* Call is not supported */ 77 NDMP0_DEVICE_BUSY_ERR, /* The device is in use */ 78 NDMP0_DEVICE_OPENED_ERR, /* Another tape or scsi device 79 * is already open */ 80 NDMP0_NOT_AUTHORIZED_ERR, /* connection has not been authorized*/ 81 NDMP0_PERMISSION_ERR, /* some sort of permission problem */ 82 NDMP0_DEV_NOT_OPEN_ERR, /* SCSI device is not open */ 83 NDMP0_IO_ERR, /* I/O error */ 84 NDMP0_TIMEOUT_ERR, /* command timed out */ 85 NDMP0_ILLEGAL_ARGS_ERR, /* illegal arguments in request */ 86 NDMP0_NO_TAPE_LOADED_ERR, /* Cannot open because there is 87 no tape loaded */ 88 NDMP0_WRITE_PROTECT_ERR, /* tape cannot be open for write */ 89 NDMP0_EOF_ERR, /* Command encountered EOF */ 90 NDMP0_EOM_ERR, /* Command encountered EOM */ 91 NDMP0_FILE_NOT_FOUND_ERR, /* File not found during restore */ 92 NDMP0_BAD_FILE_ERR, /* The file descriptor is invalid */ 93 NDMP0_NO_DEVICE_ERR, /* The device is not at that target */ 94 NDMP0_NO_BUS_ERR, /* Invalid controller */ 95 NDMP0_XDR_DECODE_ERR, /* Can't decode the request argument */ 96 NDMP0_ILLEGAL_STATE_ERR, /* Call can't be done at this state */ 97 NDMP0_UNDEFINED_ERR, /* Undefined Error */ 98 NDMP0_XDR_ENCODE_ERR, /* Can't encode the reply argument */ 99 NDMP0_NO_MEM_ERR /* no memory */ 100 }; 101 102 enum ndmp0_header_message_type 103 { 104 NDMP0_MESSAGE_REQUEST, 105 NDMP0_MESSAGE_REPLY 106 }; 107 108 enum ndmp0_message 109 { 110 NDMP0_CONNECT_OPEN = 0x900, /* CONNECT INTERFACE */ 111 NDMP0_CONNECT_CLOSE = 0x902, 112 113 NDMP0_NOTIFY_CONNECTED = 0x502 114 }; 115 116 struct ndmp0_header 117 { 118 uint32_t sequence; /* monotonically increasing */ 119 uint32_t time_stamp; /* time stamp of message */ 120 ndmp0_header_message_type message_type; /* what type of message */ 121 ndmp0_message message; /* message number */ 122 uint32_t reply_sequence; /* reply is in response to */ 123 ndmp0_error error; /* communications errors */ 124 }; 125 126 /**********************/ 127 /* CONNECT INTERFACE */ 128 /**********************/ 129 /* NDMP0_CONNECT_OPEN */ 130 struct ndmp0_connect_open_request 131 { 132 uint16_t protocol_version; /* the version of protocol supported */ 133 }; 134 135 struct ndmp0_connect_open_reply 136 { 137 ndmp0_error error; 138 }; 139 140 /* NDMP0_CONNECT_CLOSE */ 141 /* no request arguments */ 142 /* no reply arguments */ 143 144 /****************************/ 145 /* NOTIFY INTERFACE */ 146 /****************************/ 147 148 /* NDMP0_NOTIFY_CONNECTED */ 149 enum ndmp0_connect_reason 150 { 151 NDMP0_CONNECTED, /* Connect sucessfully */ 152 NDMP0_SHUTDOWN, /* Connection shutdown */ 153 NDMP0_REFUSED /* reach the maximum number of connections */ 154 }; 155 156 struct ndmp0_notify_connected_request 157 { 158 ndmp0_connect_reason reason; 159 uint16_t protocol_version; 160 string text_reason<>; 161 }; 162