Classes | Public Types | Public Member Functions | Private Attributes

data_ElementStatus Class Reference
[SCSI Library]

Element status data (media changer). More...

#include <data.h>

Inheritance diagram for data_ElementStatus:
Inheritance graph
[legend]
Collaboration diagram for data_ElementStatus:
Collaboration graph
[legend]

List of all members.

Classes

struct  ElemStatus_t

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

Detailed Description

Element status data (media changer).

Definition at line 277 of file data.h.


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 279 of file data.h.

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


Constructor & Destructor Documentation

data_ElementStatus::data_ElementStatus ( UInt32_t  a_bufSize  ) 

Definition at line 52 of file data_elementstatus.cpp.

References log_FUNC_A_m, log_WRN_m, m_buffer, and m_bufSize.

    : m_buffer(NULL),
      m_bufSize(a_bufSize) {

    if (m_bufSize > 1024 * 200) {
        log_FUNC_A_m(data_ElementStatus, "size: " << a_bufSize);
        log_WRN_m(
            "Is it really necessary to have " <<
            m_bufSize << " of buffer for element status data");
    }

    m_buffer = new UInt8_t[m_bufSize];
    memset (m_buffer, 0, sizeof(m_buffer));
}

data_ElementStatus::~data_ElementStatus (  )  [virtual]

Definition at line 67 of file data_elementstatus.cpp.

References m_buffer, and NULL.

                                        {
    if (m_buffer != NULL) {
        delete [] m_buffer, m_buffer = NULL;
    }
}


Member Function Documentation

UInt8_t * data_ElementStatus::GetBuffer (  ) 

Definition at line 73 of file data_elementstatus.cpp.

References m_buffer.

Referenced by cdb_ReadElementStatus::GetBufferPointer().

                                       {
    return m_buffer;
}

Here is the caller graph for this function:

UInt32_t data_ElementStatus::GetBufferSize (  ) 

Definition at line 77 of file data_elementstatus.cpp.

References m_bufSize.

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

                                           {
    return m_bufSize;
}

Here is the caller graph for this function:

UInt32_t data_ElementStatus::GetReportSize (  ) 

Definition at line 81 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().

                                           {
    log_FUNC_m(GetReportSize);

    data_ESHdr_t *hdr_p = 
        reinterpret_cast<data_ESHdr_t*>(m_buffer);

    UInt32_t reportSize = hton24(hdr_p->reportSize) + sizeof(data_ESHdr_t);
    log_DBG_m(dbg_NORM, "reportSize: " << reportSize);

    return reportSize;
}

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 93 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().

                                                                                           {
    log_FUNC_m(ParseElemStatus);

    data_ESHdr_t *hdr_p = 
        reinterpret_cast<data_ESHdr_t*>(m_buffer);

    vector<ElemStatus_t> elemStatusVct;

    UInt32_t reportSize = hton24(hdr_p->reportSize);
    UInt32_t elements = hton(hdr_p->elemNum);
    UInt32_t parsedElements = 0;

    log_DBG_m(dbg_NORM,
        "reportSize: " << reportSize << " " <<
        "elements: " << elements);

    if (reportSize == 0) {
        log_DBG_m(dbg_LOW, "Size of report is 0. Exiting.");
        a_esVector.clear();
        return;
    }
    if (elements == 0) {
        log_DBG_m(dbg_LOW, "Number of elements is 0. Exiting.");
        a_esVector.clear();
        return;
    }

    UInt32_t dumpSize = (reportSize > m_bufSize)? m_bufSize : reportSize;
    if (dumpSize > 2*1024) {
        dumpSize = 2*1024;
    }

    log_DBG_m(dbg_DETAIL, endl <<cmn_HexDump(m_buffer, dumpSize, 16, true) );

    UInt8_t* page_p = m_buffer + sizeof(*hdr_p);
    void*    eobuf_p = m_buffer + m_bufSize;

    while ( (page_p + sizeof(data_ESPageHdr_t)) < eobuf_p) {
         
        data_ESPageHdr_t *phdr_p = 
            reinterpret_cast<data_ESPageHdr_t*>(page_p);

        data_ElementStatus::ElemType_t type =
            static_cast<data_ElementStatus::ElemType_t>(phdr_p->elemType);

        bool pvol = (phdr_p->pvoltag == 1);
        bool avol = (phdr_p->avoltag == 1);

        UInt16_t descLen = ntoh(phdr_p->descLen);
        if (descLen == 0) {
            log_DBG_m(dbg_LOW,
                "Strange! descLen is 0. Can't continue parsing.");
            break;
        }
        UInt32_t descNum = ntoh24(phdr_p->descData) / descLen;

        log_DBG_m(dbg_NORM,
            "descLen: 0x" << hex << descLen << " " <<
            "descNum: " << dec << descNum);

        for (UInt32_t i = 0; i < descNum; i++) {
            data_ESDescriptor_t *desc_p = 
                reinterpret_cast<data_ESDescriptor_t*>
                    ( ( page_p + sizeof(*phdr_p) + i*descLen ) );

            if ( ((UInt8_t*)desc_p + descLen) > eobuf_p) {
                log_DBG_m(dbg_NORM, "Reached end of buffer. Stop parsing.");
                break;
            }

            UInt16_t slot = ntoh(desc_p->addr);

            if (desc_p->except != 0) {
                log_DBG_m(dbg_LOW,
                    "Slot: " << slot << " (" << type << ") " <<
                    "Sense: " <<
                    scsi_GetSenseAdditional(desc_p->asc, desc_p->ascq, NULL) );

                if (scsi_IsVendorSpecificASC(desc_p->asc, desc_p->ascq)) {
                    log_DBG_m(dbg_LOW, "Vendor specific ASC.");
                }
                else {
                    log_WRN_m(
                        "Element status for " << i << endl <<
                        scsi_GetSenseAdditional(desc_p->asc, desc_p->ascq, NULL));
                }
            }
            if (   desc_p->except == 0
                || scsi_IsVendorSpecificASC(desc_p->asc, desc_p->ascq)) {

                data_ElementStatus::ElemStatus_t es;

                es.type = type;
                es.slot = slot;
                es.barcode[0] = '\0';
                es.barcode2[0] = '\0';
#if TGT_OS_linux
    #warning Check standard for barcode structure
#elif TGT_OS_windows
    #pragma message ("WARNING: Check standard for barcode structure")
#endif
                if (desc_p->full == 1) {
                    es.full = true;
                    if (pvol) {
                        memcpy(es.barcode, desc_p->tag, 36);
                        es.barcode[36] = '\0';
                        
                        // Barcodes might be paddes with spaces. Get the name
                        // without the spaces.
                        // See SCSI-3 media changer commands, chapter 5.11
                        char* space_p = strchr(es.barcode, int(' ') );
                        if (space_p != NULL) {
                            *space_p = '\0';
                        }
                    }
                    if (avol) {
                        memcpy(es.barcode2, desc_p->tagAlt, 36);
                        es.barcode2[36] = '\0';
                        
                        // See comment above
                        char* space_p = strchr(es.barcode2, int(' ') );
                        if (space_p != NULL) {
                            *space_p = '\0';
                        }
                    }
                    es.srcValid = (desc_p->svalid == 1);
                    if (es.srcValid) {
                        es.srcSlot = ntoh(desc_p->srcAddr);
                    }
                }
                else {
                    es.full = false;
                }
                elemStatusVct.push_back(es);
            }
            parsedElements++;
            if (parsedElements >= elements) {
                log_DBG_m(dbg_NORM, "Parsed all elements.");
                break;
            }
        }
        if (parsedElements >= elements) {
            log_DBG_m(dbg_NORM, "Parsed all pages.");
            break;
        }

        page_p += sizeof(data_ESPageHdr_t) + ntoh24(phdr_p->descData);
    }

    // Return elements
    a_esVector.swap(elemStatusVct);

    return;
}

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 312 of file data.h.

Definition at line 315 of file data.h.

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


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