1 /* 2 BAREOS® - Backup Archiving REcovery Open Sourced 3 4 Copyright (C) 2013-2013 Planets Communications B.V. 5 Copyright (C) 2013-2013 Bareos GmbH & Co. KG 6 7 This program is Free Software; you can redistribute it and/or 8 modify it under the terms of version three of the GNU Affero General Public 9 License as published by the Free Software Foundation and included 10 in the file LICENSE. 11 12 This program is distributed in the hope that it will be useful, but 13 WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 Affero General Public License for more details. 16 17 You should have received a copy of the GNU Affero General Public License 18 along with this program; if not, write to the Free Software 19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 20 02110-1301, USA. 21 */ 22 23 /* 24 * Marco van Wieringen, November 2013 25 */ 26 27 #ifndef BAREOS_LIB_SCSI_TAPEALERT_H_ 28 #define BAREOS_LIB_SCSI_TAPEALERT_H_ 1 29 30 /* 31 * Include the SCSI Low Level Interface functions and definitions. 32 */ 33 #include "scsi_lli.h" 34 35 #define MAX_TAPE_ALERTS 64 36 37 /* 38 * SCSI CDB opcodes 39 */ 40 enum { 41 SCSI_LOG_OPCODE = 0x4d 42 }; 43 44 enum { 45 SCSI_TAPE_ALERT_FLAGS = 0x2e 46 }; 47 48 /* 49 * SCSI Control Descriptor Block 50 */ 51 typedef struct { 52 uint8_t opcode; /* Operation Code See SCSI_*_OPCODE */ 53 uint8_t res_bits_1[1]; /* Reserved, 1 byte */ 54 uint8_t pagecode; /* Page Code, 1 byte */ 55 uint8_t res_bits_2[2]; /* Reserved, 2 bytes */ 56 uint8_t parameter_pointer[2]; /* Parameter Pointer, 2 bytes, 1 bytes MSB and 1 bytes LSB */ 57 uint8_t allocation_length[2]; /* Allocation Length, 2 bytes, 1 bytes MSB and 1 bytes LSB */ 58 uint8_t control_byte; /* Control Byte */ 59 } LOG_SCSI_CDB; 60 61 typedef struct { 62 uint8_t pagecode; /* Page Code, 1 byte */ 63 uint8_t res_bits_1[1]; /* Reserved, 1 byte */ 64 uint8_t page_length[2]; /* Page Length, 2 bytes, 1 bytes MSB and 1 bytes LSB */ 65 uint8_t log_parameters[2044]; /* Log parameters (2048 bytes - 4 bytes header) */ 66 } TAPEALERT_PAGE_BUFFER; 67 68 typedef struct { 69 uint8_t parameter_code[2]; /* Parameter Code, 2 bytes */ 70 #if HAVE_BIG_ENDIAN 71 uint8_t parameter_length; /* Parameter Length, 1 byte */ 72 uint8_t disable_update:1; /* DU: Will be set to 0. The library will always update values reflected by the log parameters. */ 73 uint8_t disable_save:1; /* DS: Will be set to 1. The library does not support saving of log parameters. */ 74 uint8_t target_save_disabled:1; /* TSD: Will be set to 0. The library provides a self-defined method for saving log parameters. */ 75 uint8_t enable_threshold_comparison:1; /* ETC: Will be set to 0. No comparison to threshold values is made. */ 76 uint8_t threshold_met_criteria:2; /* TMC: Will be set to 0. Comparison to threshold values is not supported. */ 77 uint8_t list_parameter_binary:1; /* LBIN: This field is only valid if LP is set to 1. When LBIN is set to 0, the list 78 * parameter is ASCII. When LBIN is set to 1, the list parameter is a binary value. */ 79 uint8_t list_parameter:1; /* LP: This field will be set to 0 for data counters and set to 1 for list parameters */ 80 #else 81 uint8_t list_parameter:1; /* LP: This field will be set to 0 for data counters and set to 1 for list parameters */ 82 uint8_t list_parameter_binary:1; /* LBIN: This field is only valid if LP is set to 1. When LBIN is set to 0, the list 83 * parameter is ASCII. When LBIN is set to 1, the list parameter is a binary value. */ 84 uint8_t threshold_met_criteria:2; /* TMC: Will be set to 0. Comparison to threshold values is not supported. */ 85 uint8_t enable_threshold_comparison:1; /* ETC: Will be set to 0. No comparison to threshold values is made. */ 86 uint8_t target_save_disabled:1; /* TSD: Will be set to 0. The library provides a self-defined method for saving log parameters. */ 87 uint8_t disable_save:1; /* DS: Will be set to 1. The library does not support saving of log parameters. */ 88 uint8_t disable_update:1; /* DU: Will be set to 0. The library will always update values reflected by the log parameters. */ 89 uint8_t parameter_length; /* Parameter Length, 1 byte */ 90 #endif 91 uint8_t parameter_value; /* Parameter Value, n bytes */ 92 } TAPEALERT_PARAMETER; 93 94 bool GetTapealertFlags(int fd, const char *device_name, uint64_t *flags); 95 96 97 #endif /* BAREOS_LIB_SCSI_TAPEALERT_H_ */ 98