How does the agent determine the table instance that the user wants

Vasay, Al VasayA____diebold.com
Wed Nov 15 18:49:09 CET 2000


Hi,

I have two questions.  They are different but related questions:

1) I have a question about the second parameter of this method -- get_request(Request* req, int ind).  I noticed that it is always zero.  I thought that it would equal to the instance (or index) that I select from my MIB Browser.  

I'm using MG-SOFT MIB Browser for testing my subagent.  When I do a GET on a mib, the browser will prompt me to select an instance (or index) from the list (in my case, the list consists of numbers from 1 to 2 because I have two rows in my table).  Then, as soon as I select an instance, it will go to the "get_request" method.  I thought that the paramater "ind" should always be equal to the instance (or index) that I selected from the browser, but my testing tells me that it's not. Instead, "ind" is always equal to zero.

In my agent, I need to be able to know the instance (or index) that the user wants to get because my information is stored in an array and the only way I can access the data is through index.  And I thought the second parameter will give me that index.  But in my debugging, it is always equal to zero no matter what instance I select from the browser.

My question is -- What is that second parameter supposed to be? How can I determine the user-selected instance?

2) My next question is pretty much related to the first.  I was afraid that the reason why I get zero for the second parameter of the get_request method is because I'm creating my rows incorrectly.  So, how do I initialize a table with more than one row?  This is what I did:

hwSSTmmdCassetteEntry::hwSSTmmdCassetteEntry(DBDDEVICETOKEN token, const char* mibName):
DeviceMibTable(oidMmdCassetteEntry, indMmdCassetteEntry, 11, mibName)
{
            instance = this;
            add_col(new hwSSTmmdCassetteIndex(colMmdCassetteIndex, mmdToken, mibName));
            :
            Oidx ind("1");                              // create row 1 for device table
            MibTableRow* r = add_row(ind);	
            set_row(r, 0, "", 0, 0,0,0,0);

	ind = "2";                                   // create row 2 for device table
	r = add_row(ind);
	set_row(r, 0, "", 0, 0,0,0,0);
}

Is this correct? Is there an example that I can look at? 

Thank you very much,
Al Vasay
vasaya at diebold.com

Below is a snippet of the codes for my table and a leaf node:

/**********************************************************************
 *  
 *  class hwSSTmmdCassetteEntry
 * 
 **********************************************************************/
hwSSTmmdCassetteEntry::hwSSTmmdCassetteEntry(DBDDEVICETOKEN token, const char* mibName): DeviceMibTable(oidMmdCassetteEntry, indMmdCassetteEntry, 11, mibName), mmdToken(token)
{
     instance = this;
     add_col(new hwSSTmmdCassetteIndex(colMmdCassetteIndex, mmdToken, mibName));
     add_col(new hwSSTmmdCassettePartNumber(colMmdCassettePartNo, mmdToken, mibName));
     add_col(new hwSSTmmdCassetteSerialNumber(colMmdCassetteSerialNo, mmdToken, mibName));
     add_col(new hwSSTmmdCassetteNotesWidth(colMmdCassetteNotesWidth, mmdToken, mibName));
     add_col(new hwSSTmmdCassetteNotesThickness(colMmdCassetteNotesThickness, mmdToken, mibName));
     add_col(new hwSSTmmdCassetteMediaLowSensor(colMmdCassetteMediaLowSensor, mmdToken, mibName));
     add_col(new hwSSTmmdCassetteId(colMmdCassetteId, mmdToken, mibName));

     Oidx ind("1");                       // create row 1 for device table
     MibTableRow* r = add_row(ind); 
     set_row(r, 0, "", 0, 0,0,0,0);

     ind = "2";                             // create row 1 for device table
     r = add_row(ind);
     set_row(r, 0, "", 0, 0,0,0,0);
}
hwSSTmmdCassetteEntry::~hwSSTmmdCassetteEntry()
{
}
void hwSSTmmdCassetteEntry::set_row(MibTableRow* r, int p0, char* p1, int p2, int p3, int p4, int p5, int p6)
{
     r->get_nth(0)->replace_value(new SnmpInt32(p0));
     r->get_nth(1)->replace_value(new OctetStr(p1));
     r->get_nth(2)->replace_value(new SnmpInt32(p2));
     r->get_nth(3)->replace_value(new SnmpInt32(p3));
     r->get_nth(4)->replace_value(new SnmpInt32(p4));
     r->get_nth(5)->replace_value(new SnmpInt32(p5));
     r->get_nth(6)->replace_value(new SnmpInt32(p6));
}

/******************************************
 *  
 *  class hwSSTmmdCassetteIndex
 * 
 *****************************************/
hwSSTmmdCassetteIndex::hwSSTmmdCassetteIndex(const Oidx& id, DBDDEVICETOKEN token, const char* mibName):DeviceMibLeaf(id, READONLY, new SnmpInt32(), mibName),mmdToken(token),mmdName(mibName)
{

}

hwSSTmmdCassetteIndex::~hwSSTmmdCassetteIndex()
{
}

MibEntryPtr hwSSTmmdCassetteIndex::clone()
{
     MibEntryPtr other = new hwSSTmmdCassetteIndex(oid, mmdToken, mmdName);
     ((hwSSTmmdCassetteIndex*)other)->replace_value(value->clone());
     ((hwSSTmmdCassetteIndex*)other)->set_reference_to_table(my_table);
     return other;
}

void hwSSTmmdCassetteIndex::get_request(Request* req, int ind)
{
     XFSRESULT hr = 0;
     // Get the data structure for the MMD device table
     VOID* pResponse = NULL;		
     hr = InternalSPIRequest(mmdToken, WFS_MIB_MMD_CASSETTE_DATA,NULL,&pResponse);
     mmdData = (struct wfs_mmd_cassette_device_mib_data*)pResponse;

     *((SnmpInt32*)value) = mmdData->lppCassette[ind]->mmdCassIndex;
     MibLeaf::get_request(req, ind);
}





More information about the AGENTPP mailing list