data_ElementStatus Class Reference
[SCSI Library]

#include <data.h>

Inheritance diagram for data_ElementStatus:

Inheritance graph
[legend]
Collaboration diagram for data_ElementStatus:

Collaboration graph
[legend]

List of all members.


Detailed Description

Element status data (media changer).

Definition at line 263 of file data.h.


Public Types

enum  ElemType_t {
  et_ALL = 0x00, et_TRANSPORT = 0x01,
  et_SLOT = 0x02, et_IMPEX = 0x03,
  et_DRIVE = 0x04
}

Public Member Functions

 data_ElementStatus (UInt32_t a_bufSize)
virtual ~data_ElementStatus ()
UInt8_tGetBuffer ()
UInt32_t GetBufferSize ()
UInt32_t GetReportSize ()
void ParseElemStatus (vector< ElemStatus_t > &a_esVector)

Private Attributes

 log_CLASSID_m
UInt8_tm_buffer
UInt32_t m_bufSize

Classes

struct  ElemStatus_t

Member Enumeration Documentation

Enumerator:
et_ALL  All elements (CDB only).
et_TRANSPORT  Medium transport.
et_SLOT  Storage element (slot).
et_IMPEX  Import/export element.
et_DRIVE  Data transfer (tape drive).

Definition at line 265 of file data.h.

00265                  {
00267         et_ALL          = 0x00,
00269         et_TRANSPORT    = 0x01,
00271         et_SLOT         = 0x02,
00273         et_IMPEX        = 0x03,
00275         et_DRIVE        = 0x04
00276     } ElemType_t;


Constructor & Destructor Documentation

data_ElementStatus::data_ElementStatus ( UInt32_t  a_bufSize  ) 

Definition at line 38 of file data_elementstatus.cpp.

References log_FUNC_A_m, log_WRN_m, m_buffer, and m_bufSize.

00039     : m_buffer(NULL),
00040       m_bufSize(a_bufSize) {
00041 
00042     if (m_bufSize > 1024 * 200) {
00043         log_FUNC_A_m(data_ElementStatus, "size: " << a_bufSize);
00044         log_WRN_m(
00045             "Is it really necessary to have " <<
00046             m_bufSize << " of buffer for element status data");
00047     }
00048 
00049     m_buffer = new UInt8_t[m_bufSize];
00050     memset (m_buffer, 0, sizeof(m_buffer));
00051 }

data_ElementStatus::~data_ElementStatus (  )  [virtual]

Definition at line 53 of file data_elementstatus.cpp.

References m_buffer, and NULL.

00053                                         {
00054     if (m_buffer != NULL) {
00055         delete [] m_buffer, m_buffer = NULL;
00056     }
00057 }


Member Function Documentation

UInt8_t * data_ElementStatus::GetBuffer (  ) 

Definition at line 59 of file data_elementstatus.cpp.

References m_buffer.

Referenced by cdb_ReadElementStatus::GetBufferPointer().

00059                                        {
00060     return m_buffer;
00061 }

Here is the caller graph for this function:

UInt32_t data_ElementStatus::GetBufferSize (  ) 

Definition at line 63 of file data_elementstatus.cpp.

References m_bufSize.

Referenced by cdb_ReadElementStatus::cdb_ReadElementStatus(), and cdb_ReadElementStatus::GetBufferSize().

00063                                            {
00064     return m_bufSize;
00065 }

Here is the caller graph for this function:

UInt32_t data_ElementStatus::GetReportSize (  ) 

Definition at line 67 of file data_elementstatus.cpp.

References dbg_NORM, hton24(), log_DBG_m, log_FUNC_m, m_buffer, and data_ESHdr_t::reportSize.

Referenced by la_SCSILibrary::Status().

00067                                            {
00068     log_FUNC_m(GetReportSize);
00069 
00070     data_ESHdr_t *hdr_p = 
00071         reinterpret_cast<data_ESHdr_t*>(m_buffer);
00072 
00073     UInt32_t reportSize = hton24(hdr_p->reportSize) + sizeof(data_ESHdr_t);
00074     log_DBG_m(dbg_NORM, "reportSize: " << reportSize);
00075 
00076     return reportSize;
00077 }

Here is the call graph for this function:

Here is the caller graph for this function:

void data_ElementStatus::ParseElemStatus ( vector< ElemStatus_t > &  a_esVector  ) 

Definition at line 79 of file data_elementstatus.cpp.

References data_ESDescriptor_t::addr, data_ESDescriptor_t::asc, data_ESDescriptor_t::ascq, data_ESPageHdr_t::avoltag, data_ElementStatus::ElemStatus_t::barcode, data_ElementStatus::ElemStatus_t::barcode2, cmn_HexDump(), dbg_DETAIL, dbg_LOW, dbg_NORM, data_ESPageHdr_t::descData, data_ESPageHdr_t::descLen, data_ESHdr_t::elemNum, data_ESPageHdr_t::elemType, data_ESDescriptor_t::except, data_ElementStatus::ElemStatus_t::full, data_ESDescriptor_t::full, hton(), hton24(), log_DBG_m, log_FUNC_m, log_WRN_m, m_buffer, m_bufSize, ntoh(), ntoh24(), NULL, data_ESPageHdr_t::pvoltag, data_ESHdr_t::reportSize, scsi_GetSenseAdditional(), scsi_IsVendorSpecificASC(), data_ElementStatus::ElemStatus_t::slot, data_ESDescriptor_t::srcAddr, data_ElementStatus::ElemStatus_t::srcSlot, data_ElementStatus::ElemStatus_t::srcValid, data_ESDescriptor_t::svalid, data_ESDescriptor_t::tag, data_ESDescriptor_t::tagAlt, and data_ElementStatus::ElemStatus_t::type.

Referenced by la_SCSILibrary::Status(), and Status().

00079                                                                                            {
00080     log_FUNC_m(ParseElemStatus);
00081 
00082     data_ESHdr_t *hdr_p = 
00083         reinterpret_cast<data_ESHdr_t*>(m_buffer);
00084 
00085     vector<ElemStatus_t> elemStatusVct;
00086 
00087     UInt32_t reportSize = hton24(hdr_p->reportSize);
00088     UInt32_t elements = hton(hdr_p->elemNum);
00089     UInt32_t parsedElements = 0;
00090 
00091     log_DBG_m(dbg_NORM,
00092         "reportSize: " << reportSize << " " <<
00093         "elements: " << elements);
00094 
00095     if (reportSize == 0) {
00096         log_DBG_m(dbg_LOW, "Size of report is 0. Exiting.");
00097         a_esVector.clear();
00098         return;
00099     }
00100     if (elements == 0) {
00101         log_DBG_m(dbg_LOW, "Number of elements is 0. Exiting.");
00102         a_esVector.clear();
00103         return;
00104     }
00105 
00106     UInt32_t dumpSize = (reportSize > m_bufSize)? m_bufSize : reportSize;
00107     if (dumpSize > 2*1024) {
00108         dumpSize = 2*1024;
00109     }
00110 
00111     log_DBG_m(dbg_DETAIL, endl <<cmn_HexDump(m_buffer, dumpSize, 16, true) );
00112 
00113     UInt8_t* page_p = m_buffer + sizeof(*hdr_p);
00114     void*    eobuf_p = m_buffer + m_bufSize;
00115 
00116     while ( (page_p + sizeof(data_ESPageHdr_t)) < eobuf_p) {
00117          
00118         data_ESPageHdr_t *phdr_p = 
00119             reinterpret_cast<data_ESPageHdr_t*>(page_p);
00120 
00121         data_ElementStatus::ElemType_t type =
00122             static_cast<data_ElementStatus::ElemType_t>(phdr_p->elemType);
00123 
00124         bool pvol = (phdr_p->pvoltag == 1);
00125         bool avol = (phdr_p->avoltag == 1);
00126 
00127         UInt16_t descLen = ntoh(phdr_p->descLen);
00128         if (descLen == 0) {
00129             log_DBG_m(dbg_LOW,
00130                 "Strange! descLen is 0. Can't continue parsing.");
00131             break;
00132         }
00133         UInt32_t descNum = ntoh24(phdr_p->descData) / descLen;
00134 
00135         log_DBG_m(dbg_NORM,
00136             "descLen: 0x" << hex << descLen << " " <<
00137             "descNum: " << dec << descNum);
00138 
00139         for (UInt32_t i = 0; i < descNum; i++) {
00140             data_ESDescriptor_t *desc_p = 
00141                 reinterpret_cast<data_ESDescriptor_t*>
00142                     ( ( page_p + sizeof(*phdr_p) + i*descLen ) );
00143 
00144             if ( ((UInt8_t*)desc_p + descLen) > eobuf_p) {
00145                 log_DBG_m(dbg_NORM, "Reached end of buffer. Stop parsing.");
00146                 break;
00147             }
00148 
00149             UInt16_t slot = ntoh(desc_p->addr);
00150 
00151             if (desc_p->except != 0) {
00152                 log_DBG_m(dbg_LOW,
00153                     "Slot: " << slot << " (" << type << ") " <<
00154                     "Sense: " <<
00155                     scsi_GetSenseAdditional(desc_p->asc, desc_p->ascq, NULL) );
00156 
00157                 if (scsi_IsVendorSpecificASC(desc_p->asc, desc_p->ascq)) {
00158                     log_DBG_m(dbg_LOW, "Vendor specific ASC.");
00159                 }
00160                 else {
00161                     log_WRN_m(
00162                         "Element status for " << i << endl <<
00163                         scsi_GetSenseAdditional(desc_p->asc, desc_p->ascq, NULL));
00164                 }
00165             }
00166             if (   desc_p->except == 0
00167                 || scsi_IsVendorSpecificASC(desc_p->asc, desc_p->ascq)) {
00168 
00169                 data_ElementStatus::ElemStatus_t es;
00170 
00171                 es.type = type;
00172                 es.slot = slot;
00173                 es.barcode[0] = '\0';
00174                 es.barcode2[0] = '\0';
00175 #if TGT_OS_linux
00176     #warning Check standard for barcode structure
00177 #elif TGT_OS_windows
00178     #pragma message ("WARNING: Check standard for barcode structure")
00179 #endif
00180                 if (desc_p->full == 1) {
00181                     es.full = true;
00182                     if (pvol) {
00183                         memcpy(es.barcode, desc_p->tag, 36);
00184                         es.barcode[36] = '\0';
00185                         
00186                         // Barcodes might be paddes with spaces. Get the name
00187                         // without the spaces.
00188                         // See SCSI-3 media changer commands, chapter 5.11
00189                         char* space_p = strchr(es.barcode, int(' ') );
00190                         if (space_p != NULL) {
00191                             *space_p = '\0';
00192                         }
00193                     }
00194                     if (avol) {
00195                         memcpy(es.barcode2, desc_p->tagAlt, 36);
00196                         es.barcode2[36] = '\0';
00197                         
00198                         // See comment above
00199                         char* space_p = strchr(es.barcode2, int(' ') );
00200                         if (space_p != NULL) {
00201                             *space_p = '\0';
00202                         }
00203                     }
00204                     es.srcValid = (desc_p->svalid == 1);
00205                     if (es.srcValid) {
00206                         es.srcSlot = ntoh(desc_p->srcAddr);
00207                     }
00208                 }
00209                 else {
00210                     es.full = false;
00211                 }
00212                 elemStatusVct.push_back(es);
00213             }
00214             parsedElements++;
00215             if (parsedElements >= elements) {
00216                 log_DBG_m(dbg_NORM, "Parsed all elements.");
00217                 break;
00218             }
00219         }
00220         if (parsedElements >= elements) {
00221             log_DBG_m(dbg_NORM, "Parsed all pages.");
00222             break;
00223         }
00224 
00225         page_p += sizeof(data_ESPageHdr_t) + ntoh24(phdr_p->descData);
00226     }
00227 
00228     // Return elements
00229     a_esVector.swap(elemStatusVct);
00230 
00231     return;
00232 }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Reimplemented from scsi_Data.

Definition at line 298 of file data.h.

Definition at line 301 of file data.h.

Referenced by data_ElementStatus(), GetBufferSize(), and ParseElemStatus().


The documentation for this class was generated from the following files:

Generated on Mon Feb 27 19:06:39 2012 for OPENARCHIVE by  doxygen 1.5.6