1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253
|
/*
* ipmi_entity.cpp
*
* Copyright (c) 2003,2004 by FORCE Computers
* Copyright (c) 2005 by ESO Technologies.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. This
* file and program are licensed under a BSD style license. See
* the Copying file included with the OpenHPI distribution for
* full licensing terms.
*
* Authors:
* Thomas Kanngieser <thomas.kanngieser@fci.com>
* Pierre Sangouard <psangouard@eso-tech.com>
*/
#include <string.h>
#include <stdlib.h>
#include <glib.h>
#include <assert.h>
#include <oh_utils.h>
#include "ipmi_entity.h"
#include "ipmi_log.h"
#include <oh_utils.h>
static const char *entity_id_types[] =
{
"Unspecified",
"Other",
"Unknown",
"Processor",
"Disk",
"Peripheral",
"SystemManagementModule",
"SystemBoard",
"MemoryModule",
"ProcessorModule",
"PowerSupply",
"AddInCard",
"FrontPanelBoard",
"BackPanelBoard",
"PowerSystemBoard",
"DriveBackplane",
"SystemInternalExpansionBoard",
"OtherSystemBoard",
"ProcessorBoard",
"PowerUnit",
"PowerModule",
"PowerManagementBoard",
"ChassisBackPanelBoard",
"SystemChassis",
"SubChassis",
"OtherChassisBoard",
"DiskDriveBay",
"PeripheralBay",
"DeviceBay",
"FanCooling",
"CoolingUnit",
"CableInterconnect",
"MemoryDevice",
"SystemManagementSoftware",
"Bios",
"OperatingSystem",
"SystemBus",
"Group",
"RemoteMgmtCommDevice",
"ExternalEnvironment",
"Battery",
"ProcessingBlade",
"ConnectivitySwitch",
"ProcessorMemoryModule",
"IoModule",
"ProcessorIoModule",
"ManagementControllerFirmware",
};
#define dNumEntityIdTypes (sizeof(entity_id_types)/sizeof(char *))
const char *
IpmiEntityIdToString( tIpmiEntityId val )
{
if ( (unsigned int)val < dNumEntityIdTypes )
return entity_id_types[val];
switch( val )
{
case eIpmiEntityIdPicMgFrontBoard:
return "PicmgFrontBoard";
case eIpmiEntityIdPicMgRearTransitionModule:
return "PicmgRearTransitionModule";
case eIpmiEntityIdPicMgAdvancedMcModule:
return "PicMgAdvancedMcModule";
case eIpmiEntityIdPicMgMicroTcaCarrierHub:
return "PicMgMicroTcaCarrierHub";
case eIpmiEntityIdPicmgShelfManager:
return "PicmgShelfManager";
case eIpmiEntityIdPicmgFiltrationUnit:
return "PicmgFiltrationUnit";
case eIpmiEntityIdPicmgShelfFruInformation:
return "PicmgShelfFruInformation";
case eIpmiEntityIdPicmgAlarmPanel:
return "PicmgAlarmPanel";
default:
break;
}
return "Invalid";
}
cIpmiEntityPath::cIpmiEntityPath()
{
memset( &m_entity_path, 0, sizeof( SaHpiEntityPathT ) );
}
cIpmiEntityPath::cIpmiEntityPath( const SaHpiEntityPathT &entity_path )
{
m_entity_path = entity_path;
}
void
cIpmiEntityPath::SetEntry( int idx, SaHpiEntityTypeT type,
SaHpiEntityLocationT instance )
{
assert( idx >= 0 && idx < SAHPI_MAX_ENTITY_PATH );
m_entity_path.Entry[idx].EntityType = type;
m_entity_path.Entry[idx].EntityLocation = instance;
}
SaHpiEntityTypeT
cIpmiEntityPath::GetEntryType( int idx )
{
assert( idx >= 0 && idx < SAHPI_MAX_ENTITY_PATH );
return m_entity_path.Entry[idx].EntityType;
}
void
cIpmiEntityPath::SetEntryType( int idx, SaHpiEntityTypeT type )
{
assert( idx >= 0 && idx < SAHPI_MAX_ENTITY_PATH );
m_entity_path.Entry[idx].EntityType = type;
}
SaHpiEntityLocationT
cIpmiEntityPath::GetEntryInstance( int idx )
{
assert( idx >= 0 && idx < SAHPI_MAX_ENTITY_PATH );
return m_entity_path.Entry[idx].EntityLocation;
}
void
cIpmiEntityPath::SetEntryInstance( int idx,
SaHpiEntityLocationT instance )
{
assert( idx >= 0 && idx < SAHPI_MAX_ENTITY_PATH );
m_entity_path.Entry[idx].EntityLocation = instance;
}
cIpmiEntityPath &
cIpmiEntityPath::operator+=( const cIpmiEntityPath &epath )
{
oh_concat_ep( &m_entity_path, &epath.m_entity_path );
return *this;
}
bool
cIpmiEntityPath::operator==( const cIpmiEntityPath &epath ) const
{
SaHpiBoolT cmp_result;
cmp_result = oh_cmp_ep( &m_entity_path, &epath.m_entity_path );
if ( cmp_result == SAHPI_TRUE )
return true;
else
return false;
}
bool
cIpmiEntityPath::operator!=( const cIpmiEntityPath &epath ) const
{
SaHpiBoolT cmp_result;
cmp_result = oh_cmp_ep( &m_entity_path, &epath.m_entity_path );
if ( cmp_result == SAHPI_TRUE )
return false;
else
return true;
}
void
cIpmiEntityPath::AppendRoot( int idx )
{
assert( idx >= 0 && idx < SAHPI_MAX_ENTITY_PATH );
m_entity_path.Entry[idx].EntityType = SAHPI_ENT_ROOT;
m_entity_path.Entry[idx].EntityLocation = 0;
}
cIpmiLog &
operator<<( cIpmiLog &log, const cIpmiEntityPath &epath )
{
oh_big_textbuffer path_text;
char str[OH_MAX_TEXT_BUFFER_LENGTH+1];
oh_decode_entitypath( &epath.m_entity_path, &path_text );
memcpy( str, path_text.Data, path_text.DataLength );
str[path_text.DataLength] = 0;
log << str;
return log;
}
bool
cIpmiEntityPath::FromString( const char *str )
{
return oh_encode_entitypath( str, &m_entity_path ) ? false : true;
}
|