Hello!
This is my first time to use table OID for Agent++. I want to create a READONLY table with 9 columns (1 SnmpInt32+2 OctetStr rows+6 Gauge32) and 64 rows. I’m trying to follow examples in atm_mib and agent++2.pdf but still dont understand.
1- define table+entry+columns in atm_mib.h
#define oidAtmVclTable “1.3.6.1.2.1.37.1.7”
#define oidAtmVclEntry “1.3.6.1.2.1.37.1.7.1”
#define oidAtmVclVpi “1.3.6.1.2.1.37.1.7.1.1”
#define colAtmVclVpi “1”
#define oidAtmVclVci “1.3.6.1.2.1.37.1.7.1.2”
#define colAtmVclVci “2”
#define oidAtmVclAdminStatus “1.3.6.1.2.1.37.1.7.1.3”
#define colAtmVclAdminStatus “3”
…
#define oidAtmVclRowStatus “1.3.6.1.2.1.37.1.7.1.13”
#define colAtmVclRowStatus “13”
#define oidAtmVclCastType “1.3.6.1.2.1.37.1.7.1.14”
#define colAtmVclCastType “14”
#define oidAtmVclConnKind “1.3.6.1.2.1.37.1.7.1.15”
#define colAtmVclConnKind “15”
2- Create class for Entry and Columns. but I dont know why example did not create column #1 for AtmVclVpi and column #2 for AtmVclVci. Also, set_row function only define from p0 to p12. I think set_row does not have column #1 for AtmVclVpi and column #2 for AtmVclVci.
class atmVclRowStatus: public snmpRowStatus {
public:
atmVclRowStatus(const Oidx&);
virtual ~atmVclRowStatus();
virtual MibEntryPtr clone();
};
…
class atmVclConnKind: public SimMibLeaf {
public:
atmVclConnKind(const Oidx&);
virtual ~atmVclConnKind();
virtual MibEntryPtr clone();
virtual int prepare_set_request(Request*, int&);
virtual bool value_ok(const Vbx&);
};
…
class atmVclEntry: public MibTable {
public:
atmVclEntry();
virtual ~atmVclEntry();
static atmVclEntry* instance;
virtual void set_row(MibTableRow* r, int p0, int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, int p9, int p10, int p11, int p12);
};
3- in atm_mib.cpp, example has index_info indAtmVclEntry[3]. Why there are 3 index (other examples use 1 or different index)? should I use 64 index for my case with 64 rows? How to select correct SYNTAX and max/min (other examples use sNMP_SYNTAX_OCTETS or something else)
const index_info indAtmVclEntry[3] = {
{ sNMP_SYNTAX_INT, FALSE, 1, 1 },
{ sNMP_SYNTAX_INT, FALSE, 1, 1 },
{ sNMP_SYNTAX_INT, FALSE, 1, 1 } };
struct index_info {
NS_SNMP SmiUINT32 type;
bool implied;
unsigned int min;
unsigned int max;
};
4- in atm_mib.cpp, example has add_row(“1.32.64”) what does it mean? how does we add new rows (since there are 64 rows) and update READONLY columns values? I saw set_row(r, 1, 2, 0, 0, 0, 0, 1500, 1500, 0, 1, 2, 0, 0) but since they are READONLY columns do we need to start_synch(); ->set_value() ->end_synch() those oidAtmVclCastType “1.3.6.1.2.1.37.1.7.1.14” or colAtmVclCastType “14”? do we have some examples or documents somewhere I can take a look?
atmVclEntry::atmVclEntry():
MibTable(oidAtmVclEntry, indAtmVclEntry, 3)
{
instance = this;
add_col(new atmVclAdminStatus(colAtmVclAdminStatus));
…
add_col(new atmVclConnKind(colAtmVclConnKind));
MibTableRow* r = add_row(“1.32.64”);
set_row(r, 1, 2, 0, 0, 0, 0, 1500, 1500, 0, 1, 2, 0, 0);
}
void atmVclEntry::set_row(MibTableRow* r, int p0, int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, int p9, int p10, int p11, int p12)
{
r->get_nth(0)->replace_value(new SnmpInt32(p0));
…
r->get_nth(12)->replace_value(new SnmpInt32(p12));
}