File: ipmi_inventory_parser.h

package info (click to toggle)
openhpi 2.14.1-1.2
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 20,380 kB
  • sloc: ansic: 187,087; cpp: 32,188; sh: 10,415; makefile: 4,467; perl: 1,529
file content (200 lines) | stat: -rw-r--r-- 6,058 bytes parent folder | download | duplicates (9)
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

/*
 * ipmi_inventory_parser.h
 *
 * Copyright (c) 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>
 */

#ifndef dIpmiInventoryParser_h
#define dIpmiInventoryParser_h


#ifndef dArray_h
#include "array.h"
#endif

#ifndef dIpmiTextBuffer
#include "ipmi_text_buffer.h"
#endif


unsigned char IpmiChecksum( const unsigned char *data, int size );
unsigned char IpmiChecksumMulti( const unsigned char *data, int size, unsigned char csum );

enum tIpmiInventoryRecordType
{
  eIpmiInventoryRecordTypeInternal,
  eIpmiInventoryRecordTypeChassis,
  eIpmiInventoryRecordTypeBoard,
  eIpmiInventoryRecordTypeProduct,
  eIpmiInventoryRecordTypeMultiRecord,
  eIpmiInventoryRecordTypeLast
};

const char *IpmiInventoryRecordTypeToString( tIpmiInventoryRecordType );

#define eIpmiInventoryMultiRecordTypeOemFirst   0xc0
#define eIpmiInventoryMultiRecordTypeOemLast    0xff

class cIpmiInventoryField
{
  cIpmiTextBuffer   m_ipmi_text_buffer;
  SaHpiIdrFieldT    m_idr_field;

public:
  cIpmiInventoryField(SaHpiEntryIdT area_id,
                        SaHpiEntryIdT field_id,
                        SaHpiIdrFieldTypeT field_type);
  virtual ~cIpmiInventoryField();

  void                  SetAscii( char *str, int size );
  void                  SetBinary( const unsigned char *data, unsigned int size );
  SaHpiEntryIdT         FieldId() const { return m_idr_field.FieldId; }
  SaHpiIdrFieldTypeT    FieldType() const { return m_idr_field.Type; }
  SaHpiIdrFieldT        Field() const { return m_idr_field; }

  SaErrorT ReadTextBuffer( const unsigned char *&data, unsigned int &size );
};

class cIpmiInventoryArea
{
protected:
  SaHpiEntryIdT                 m_field_id;
  SaHpiIdrAreaHeaderT           m_area_header;
  cArray<cIpmiInventoryField>   m_field_array;

public:
  cIpmiInventoryArea(SaHpiEntryIdT area_id);
  virtual ~cIpmiInventoryArea();

  cIpmiInventoryField *FindIdrField( SaHpiIdrFieldTypeT fieldtype,
                                     SaHpiEntryIdT fieldid );

  SaErrorT GetIdrField( SaHpiIdrFieldTypeT &fieldtype,
                        SaHpiEntryIdT &fieldid,
		                SaHpiEntryIdT &nextfieldid,
                        SaHpiIdrFieldT &field );

  SaHpiEntryIdT         AreaId() const { return m_area_header.AreaId; }
  SaHpiIdrAreaTypeT     AreaType() const { return m_area_header.Type; }
  SaHpiIdrAreaHeaderT   AreaHeader() const { return m_area_header; }


  virtual SaErrorT     ParseFruArea( const unsigned char *data, unsigned int size ) = 0;


};

class cIpmiInventoryAreaInternal : public cIpmiInventoryArea
{

public:
  cIpmiInventoryAreaInternal(SaHpiEntryIdT area_id);
  virtual ~cIpmiInventoryAreaInternal();

  virtual SaErrorT     ParseFruArea( const unsigned char *data, unsigned int size );
};

class cIpmiInventoryAreaMultiRecord : public cIpmiInventoryArea
{

public:
  cIpmiInventoryAreaMultiRecord(SaHpiEntryIdT area_id);
  virtual ~cIpmiInventoryAreaMultiRecord();

  virtual SaErrorT     ParseFruArea( const unsigned char *data, unsigned int size );
};

class cIpmiInventoryAreaChassis : public cIpmiInventoryArea
{

public:
  cIpmiInventoryAreaChassis(SaHpiEntryIdT area_id);
  virtual ~cIpmiInventoryAreaChassis();

  virtual SaErrorT     ParseFruArea( const unsigned char *data, unsigned int size );
};

class cIpmiInventoryAreaBoard : public cIpmiInventoryArea
{

public:
  cIpmiInventoryAreaBoard(SaHpiEntryIdT area_id);
  virtual ~cIpmiInventoryAreaBoard();

  virtual SaErrorT     ParseFruArea( const unsigned char *data, unsigned int size );
};

class cIpmiInventoryAreaProduct : public cIpmiInventoryArea
{

public:
  cIpmiInventoryAreaProduct(SaHpiEntryIdT area_id);
  virtual ~cIpmiInventoryAreaProduct();

  virtual SaErrorT     ParseFruArea( const unsigned char *data, unsigned int size );
};

class cIpmiInventoryParser
{
  SaHpiIdrInfoT                 m_idr_info;
  SaHpiEntryIdT                 m_area_id;
  cArray<cIpmiInventoryArea>    m_area_array;

public:
  cIpmiInventoryParser();
  virtual ~cIpmiInventoryParser();

  cIpmiInventoryArea *AllocArea( SaHpiEntryIdT area_id, tIpmiInventoryRecordType type );


  virtual SaErrorT     ParseFruInfo( const unsigned char *data, unsigned int size, unsigned int idr_id );

  cIpmiInventoryArea *FindIdrArea( SaHpiIdrAreaTypeT areatype, SaHpiEntryIdT areaid );


  virtual SaErrorT GetIdrInfo( SaHpiIdrIdT &idrid, SaHpiIdrInfoT &idrinfo );

  virtual SaErrorT GetIdrAreaHeader( SaHpiIdrIdT &idrid,
                                     SaHpiIdrAreaTypeT &areatype,
			                         SaHpiEntryIdT &areaid,
                                     SaHpiEntryIdT &nextareaid,
                                     SaHpiIdrAreaHeaderT &header );

  virtual SaErrorT AddIdrArea( SaHpiIdrIdT &idrid,
                               SaHpiIdrAreaTypeT &areatype,
			                   SaHpiEntryIdT &areaid );

  virtual SaErrorT DelIdrArea( SaHpiIdrIdT &idrid, SaHpiEntryIdT &areaid );

  virtual SaErrorT GetIdrField( SaHpiIdrIdT &idrid,
                                SaHpiEntryIdT &areaid,
                                SaHpiIdrFieldTypeT &fieldtype,
                                SaHpiEntryIdT &fieldid,
			                    SaHpiEntryIdT &nextfieldid,
                                SaHpiIdrFieldT &field );

  virtual SaErrorT AddIdrField( SaHpiIdrIdT &idrid, SaHpiIdrFieldT &field );

  virtual SaErrorT SetIdrField( SaHpiIdrIdT &idrid, SaHpiIdrFieldT &field );

  virtual SaErrorT DelIdrField( SaHpiIdrIdT &idrid,
                                SaHpiEntryIdT &areaid,
                                SaHpiEntryIdT &fieldid );

};


#endif