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-const-variable" 64 %#elif __GNUC__ 65 %#if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 402 66 %#pragma GCC diagnostic ignored "-Wunused-variable" 67 %#endif 68 %#endif 69 70 const NDMPPORT = 10000; 71 72 enum ndmp0_error 73 { 74 NDMP0_NO_ERR, /* No error */ 75 NDMP0_NOT_SUPPORTED_ERR, /* Call is not supported */ 76 NDMP0_DEVICE_BUSY_ERR, /* The device is in use */ 77 NDMP0_DEVICE_OPENED_ERR, /* Another tape or scsi device 78 * is already open */ 79 NDMP0_NOT_AUTHORIZED_ERR, /* connection has not been authorized*/ 80 NDMP0_PERMISSION_ERR, /* some sort of permission problem */ 81 NDMP0_DEV_NOT_OPEN_ERR, /* SCSI device is not open */ 82 NDMP0_IO_ERR, /* I/O error */ 83 NDMP0_TIMEOUT_ERR, /* command timed out */ 84 NDMP0_ILLEGAL_ARGS_ERR, /* illegal arguments in request */ 85 NDMP0_NO_TAPE_LOADED_ERR, /* Cannot open because there is 86 no tape loaded */ 87 NDMP0_WRITE_PROTECT_ERR, /* tape cannot be open for write */ 88 NDMP0_EOF_ERR, /* Command encountered EOF */ 89 NDMP0_EOM_ERR, /* Command encountered EOM */ 90 NDMP0_FILE_NOT_FOUND_ERR, /* File not found during restore */ 91 NDMP0_BAD_FILE_ERR, /* The file descriptor is invalid */ 92 NDMP0_NO_DEVICE_ERR, /* The device is not at that target */ 93 NDMP0_NO_BUS_ERR, /* Invalid controller */ 94 NDMP0_XDR_DECODE_ERR, /* Can't decode the request argument */ 95 NDMP0_ILLEGAL_STATE_ERR, /* Call can't be done at this state */ 96 NDMP0_UNDEFINED_ERR, /* Undefined Error */ 97 NDMP0_XDR_ENCODE_ERR, /* Can't encode the reply argument */ 98 NDMP0_NO_MEM_ERR /* no memory */ 99 }; 100 101 enum ndmp0_header_message_type 102 { 103 NDMP0_MESSAGE_REQUEST, 104 NDMP0_MESSAGE_REPLY 105 }; 106 107 enum ndmp0_message 108 { 109 NDMP0_CONNECT_OPEN = 0x900, /* CONNECT INTERFACE */ 110 NDMP0_CONNECT_CLOSE = 0x902, 111 112 NDMP0_NOTIFY_CONNECTED = 0x502 113 }; 114 115 struct ndmp0_header 116 { 117 uint32_t sequence; /* monotonically increasing */ 118 uint32_t time_stamp; /* time stamp of message */ 119 ndmp0_header_message_type message_type; /* what type of message */ 120 ndmp0_message message; /* message number */ 121 uint32_t reply_sequence; /* reply is in response to */ 122 ndmp0_error error; /* communications errors */ 123 }; 124 125 /**********************/ 126 /* CONNECT INTERFACE */ 127 /**********************/ 128 /* NDMP0_CONNECT_OPEN */ 129 struct ndmp0_connect_open_request 130 { 131 uint16_t protocol_version; /* the version of protocol supported */ 132 }; 133 134 struct ndmp0_connect_open_reply 135 { 136 ndmp0_error error; 137 }; 138 139 /* NDMP0_CONNECT_CLOSE */ 140 /* no request arguments */ 141 /* no reply arguments */ 142 143 /****************************/ 144 /* NOTIFY INTERFACE */ 145 /****************************/ 146 147 /* NDMP0_NOTIFY_CONNECTED */ 148 enum ndmp0_connect_reason 149 { 150 NDMP0_CONNECTED, /* Connect sucessfully */ 151 NDMP0_SHUTDOWN, /* Connection shutdown */ 152 NDMP0_REFUSED /* reach the maximum number of connections */ 153 }; 154 155 struct ndmp0_notify_connected_request 156 { 157 ndmp0_connect_reason reason; 158 uint16_t protocol_version; 159 string text_reason<>; 160 }; 161